cancel
Showing results for 
Search instead for 
Did you mean: 

Allocating DMA buffers on Heap

Ariel1
Associate III

Hi everyone, 

I was wondering if is it valid to allocate DMA buffers for USART/SPI etc.. on the heap using aligned_alloc() function?

My board is the NUCLEO-H743ZI2 

 

If its possible - is it good practice?

Thanks, Ariel

2 REPLIES 2
Andrew Neil
Super User

"heap" is purely a software abstraction.

The DMA itself neither knows not cares anything about "heap" - it just works with hardware addresses.

The usual issues of heap in embedded applications would still apply.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
TDK
Super User

> If its possible - is it good practice?

Dynamically allocated memory on a microcontroller is generally frowned upon, but opinions will vary. It introduces possibilities for code bugs that do not exist with static allocation.

If you feel a post has answered your question, please click "Accept as Solution".