cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing data stored in DMA memory by USART

waleedaslam89
Associate II
Posted on July 11, 2012 at 13:55

Hello ,

I am new to STM32. I am reading data from USART using DMA. I dont know how to directly access data from DMA memory after transfer complete interrupt.

5 REPLIES 5
Posted on July 11, 2012 at 14:53

Just like any other memory. Use pointers or array access.

If you passed &Buffer to the DMA controller as the transfer address, then Buffer[i]

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
waleedaslam89
Associate II
Posted on July 12, 2012 at 06:29

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6lD&d=%2Fa%2F0X0000000bum%2F6bueM3fOabdBer.C.5DXX1eBEgsmK3XuJ79ux1PJWFk&asPdf=false
Posted on July 12, 2012 at 11:47

uint8_t *BufferStart = (uint8_t *)0x20004000; // An Address in RAM

uint32_t BufferSize = 10240;

..

DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)BufferStart;

DMA_InitStructure.DMA_BufferSize = (uint16_t)BufferSize;

..

for(i=0; i<BufferSize; i++)

 sum += BufferStart[i];

Although I can't see why you couldn't statically allocate the buffer.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
waleedaslam89
Associate II
Posted on July 12, 2012 at 12:54

Thanks for your reply,

Actually i am confused in a little bit different manner. For example if I give this Address (e.g 0x20004000) to DMA to start writing from here, and if in my code there are many local functions that create random variables , so is it possible that DMA may corrupt these variables (because DMA only knows the starting address and buffer size ). 

Pls clarify me in this regard.

 

Posted on July 12, 2012 at 15:18

Which is why most of us would statically allocate such buffers, or carve out some space by modifying the linker script or scatter file.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..