cancel
Showing results for 
Search instead for 
Did you mean: 

How to increment STM32 DMA destination address by custom step size

SChar.21
Associate

Hi, 

I am using the STM32U575.

In my application, I have to transfer ADC readings to a destination buffer. I have set the DMA source address to the ADC data register (16-bit), and the destination address to a memory buffer start address. The data width is 16-bits or half word, as per the STM32 size definitions.

My requirement is that I need to fill the ADC 1024 samples into the memory and after receiving these, transfer them to another buffer, that is connected to a UART, to be transmitted out.

However, I need to increment the DMA destination buffer address by 32 bits, after each sample from the ADC, meaning, leave alternate half words empty. 

The data would look like this in the memory buffer:

ADDR 0: fill with sample 1 (16 bits)   - increment DMA destination address by one word (32-bits)

ADDR 2: empty - 16- bits

ADDR4: fill with sample 2 (16 bits) - increment DMA destination address by one word (32-bits)

ADDR6: empty - 16 bits

........

and so on till the 1024th location.

But in the DMA settings, the address increment value options do not have such a choice. 

Is there any way to achieve this? 

Any ideas are welcome  .. :)

 

 

1 REPLY 1
Karl Yamashita
Principal

If you're using DMA in circular mode, then no. You'll have to copy the HT/TC data to another buffer.

If using Normal mode, then after each callback, you can pass the memory address to the DMA for the next conversion.

 

Why don't you just put the ADC data into a UART transmit buffer on each callback? Then in your polling routine you can transmit the available data in the transmit buffer. The receiving end can have queues of 1024 packets. So as 1 queue is being parsed, the other queue(s) are being filled. 

Don't worry, I won't byte.
TimerCallback tutorial! | UART and DMA Idle tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.