cancel
Showing results for 
Search instead for 
Did you mean: 

DMA working in a strange way

sonurobots
Associate III
Posted on July 19, 2013 at 08:13

first of all the DMA code:

void DMA_Config(uint32_t addr)

{

//int addr=&ipbuffer;

NVIC_InitTypeDef NVIC_InitStructure;

DMA_InitTypeDef  DMA_InitStructure;

/* Enable DMA clock */

RCC_AHB1PeriphClockCmd(DMA_STREAM_CLOCK, ENABLE);

/* Reset DMA Stream registers (for debug purpose) */

DMA_DeInit(DMA_STREAM);

while (DMA_GetCmdStatus(DMA_STREAM) != DISABLE)

{

}

/* Configure DMA Stream */

DMA_InitStructure.DMA_Channel = DMA_CHANNEL;

DMA_InitStructure.DMA_PeripheralBaseAddr =addr;

DMA_InitStructure.DMA_Memory0BaseAddr =0x60010000;  //FSMC address

DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToMemory;

DMA_InitStructure.DMA_BufferSize =480; //(uint32_t)BUFFER_SIZE;

DMA_InitStructure.DMA_PeripheralInc =DMA_PeripheralInc_Enable;

DMA_InitStructure.DMA_MemoryInc =DMA_MemoryInc_Disable;

DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;

DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;//DMA_MemoryDataSize_Word;

DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;

DMA_InitStructure.DMA_Priority = DMA_Priority_High;

DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;

DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;

DMA_InitStructure.DMA_MemoryBurst =DMA_MemoryBurst_Single;

DMA_InitStructure.DMA_PeripheralBurst =DMA_PeripheralBurst_Single;

DMA_Init(DMA_STREAM, &DMA_InitStructure);

/* Enable DMA Stream Transfer Complete interrupt */

//DMA_ITConfig(DMA_STREAM, DMA_IT_TC, ENABLE);

/* DMA Stream enable */

DMA_Cmd(DMA_STREAM, ENABLE);

//interrupt enable

NVIC_InitStructure.NVIC_IRQChannel = DMA_STREAM_IRQ;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

}

when i call 

  addr=&buffer[0]+4;

   DMA_Config(addr);this works perfectly

 I have checked the addr its 536903104 when i call addr=&buffer[0];

and  536903108 when i call addr=&buffer[1];

but both of these calls dont work .it only works whwn i call  addr=&buffer[0]+4;then DMA_Config(addr);

can anyone explain whats happening ?
3 REPLIES 3
Posted on July 19, 2013 at 10:42

You might want to enable this

DMA_InitStructure.DMA_MemoryInc =DMA_MemoryInc_Disable; // ????

It would help if you provided the defines, and explained a bit better what the data patterns were you were trying to copy, and what the resultant failure modes actually produced.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
sonurobots
Associate III
Posted on July 19, 2013 at 12:49

first of all thanks for your quick replay.

 

DMA_InitStructure.DMA_MemoryInc =DMA_MemoryInc_Disable; // ????

i am doing so because i am sending it to a LCD. that has one RS line  to select between RAM and registers.

the buffer contains some rgb data. the error  is everything gets transferred to LCD but in a distorted way. it seems like red color is high and blue is low.

my image is in blue but it looks like its in red. 

the buffer is the output for libjpeg  that converts jpeg to rgb row. 

here are my defines....

#define DMA_STREAM               DMA2_Stream0

#define DMA_CHANNEL              DMA_Channel_0

#define DMA_STREAM_CLOCK         RCC_AHB1Periph_DMA2

#define DMA_STREAM_IRQ           DMA2_Stream0_IRQn

#define DMA_IT_TCIF              DMA_IT_TCIF0

#define DAM_STREAM_IRQHANDLER    DMA2_Stream0_IRQHandler

Posted on July 19, 2013 at 12:59

Sounds more like the video data formats are not coherent between the source and destination.

Look very carefully at the spec for the LCD, and the bit/byte ordering of the data it expects.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..