DMA buffers declaration

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
josesimoes
Posts: 91
Joined: Sat Feb 18, 2017 11:50 am
Has thanked: 43 times
Been thanked: 23 times

DMA buffers declaration

Post by josesimoes »

Hi,

I have a question regarding the best way (or should I say requirement?) to declare the buffers for DMA read/write with SPI or UART drivers.
The samples always have those declared as static byte arrays. I get that because pointers must be passed to the drivers.
The arrays can't be declared as variables inside a function (when using async calls on the drivers), correct?

Questions:
1) would it be OK to use malloc to create those buffers and release them after the driver "transaction" is completed?
2) if the platform is an STM32F7 or STM32H7 are there any further requirements because of memory caching and such?

Thanks in advance!
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: DMA buffers declaration

Post by Giovanni »

Hi,

You can create buffers anywhere, even in stack frames, as long the variable is "alive" until the operation finishes.

Devices with cache have other restrictions because coherency and/or areas not reachable by DMAs, this is device specific.

Giovanni
Post Reply