DMA buffers declaration

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

Moderators: barthess, RoccoMarco

josesimoes
Posts: 60
Joined: Sat Feb 18, 2017 11:50 am
Has thanked: 24 times
Been thanked: 14 times

DMA buffers declaration

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

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: 11153
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 391 times
Been thanked: 322 times
Contact:

Re: DMA buffers declaration

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

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


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 4 guests