2025-11-11 11:35 AM - last edited on 2025-11-13 8:59 AM by mƎALLEm
Good day!
I use TIM15 and DMA1, channel 5 in STM32H743. If DMA and data have a size of 32-bit, then everything works fine. If you configure DMA on 16-bit data, then 32-bit data is still written to the TIM5 registers.
In order to save memory, I want to write 16-bit values to the timer. In the documentation I read that DMA1 works only in 32-bit data mode.
Is there any way to force DMA1 to transfer data to the timer in 16-bit mode, or even better in 8-bit?
Andrey.
2025-11-11 12:22 PM
Hi,
so you want write 16b to a timer register ?
And you set data and destination to 16b ?
then..?
2025-11-11 1:38 PM
This won't work and you cannot save memory, the data for TIM5 have to be 32-bit.
DMA1 is a dual-port DMA (i.e. the same as in'F2/'F4/'F7), and does not zero-extend the data. It means, that if you set it to 16-bit at the memory side and 32-bit at peripheral side, it will assemble (concatenate) two halfwords from memory to a word tp output to the timer. If you set 16-bit at both memory and peripheral side, it will indeed write only 16 bits onto the AHB bus towards TIM5, but the AHB/APB bridge will copy the lower 16 bits to the upper 16 bits and both halves will be written to the timer.
At least this is what happens in 'F4; I don't use the'H7. Try.
JW
2025-11-11 1:51 PM
but Tim15 is 16b timer, so register with 16b write should work - or not ?
2025-11-11 2:17 PM
For TIM15 yes, but OP mentioned both TIM15 and TIM5.
JW
2025-11-12 4:44 AM
Thanks for the reply. You are right. When I write a 16-bit value to TIM15 using DMA1 in HalfWord mode, a 32-bit value consisting of two 16-bit values is written to the register. While studying the manual, I found a note that says the AHB bus only works in 32-bit format.
The user manual explains that DMA1 can't write, for example, 8-bit data to 32-bit registers. It won't pad the high-order bits with zeros. This means I can't save memory and will have to store all data in 32-bit format.
The BDMA module can pad the high-order bits with zeros. However, this module can't send data to the TIM15 because it uses the DMAMUX2, which doesn't have a TIM15 channel.
I'd like to know if it's possible to preserve memory and send 16-bit values (ideally 8-bit) to the timer instead of 32-bit values?
2025-11-13 6:53 AM - edited 2025-11-13 6:53 AM
> When I write a 16-bit value to TIM15 using DMA1 in HalfWord mode, a 32-bit value consisting of two 16-bit values is written to the register.
So, do you work with TIM5 or TIM15?
If TIM15, then question is, which register are you trying to write to, as TIM15 is a 16-bit timer.
> While studying the manual, I found a note that says the AHB bus only works in 32-bit format.
This is not related to your problem. This says, that DMA's registers can't be accessed in other than 32-bit way, i.e. the processor has to write DMA's registers only using instructions with 32 bit data; this does not say, how DMA accesses other peripherals.
> I'd like to know if it's possible to preserve memory and send 16-bit values (ideally 8-bit) to the timer instead of 32-bit values?
No, it is not possible.
JW
2025-11-13 7:14 AM
Thanks for the reply. I'm working with TIM15. I'm writing three register values (ARR, RCR, CCR1) to the DMAR register.
2025-11-13 8:39 AM
And what effect do you observe due to the "lower halfword duplicated to upper halfword"?
Can you please post the read-out content of those registers after such write occured?
JW
2025-11-14 2:44 AM
Thanks for your help. I figured out the problem. The peripheral register size was incorrectly specified (32 bits instead of 16 bits) and the RCR register value for timer 15 was incorrect.
Andrey.