Skip to main content
Associate III
July 28, 2025
Question

Allocating DMA buffers on Heap

  • July 28, 2025
  • 2 replies
  • 234 views

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

Andrew Neil
Super User
July 28, 2025

"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
July 28, 2025

> 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""."