DMA buffers declaration

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

Moderators: barthess, RoccoMarco

Posts: 71
Joined: Sat Feb 18, 2017 11:50 am
Has thanked: 31 times
Been thanked: 17 times

DMA buffers declaration

Postby josesimoes » Mon Apr 30, 2018 12:38 pm


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?

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
Site Admin
Posts: 11647
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 488 times
Been thanked: 409 times

Re: DMA buffers declaration

Postby Giovanni » Mon Apr 30, 2018 12:50 pm


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.


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 4 guests