PWM with DMA makes unwanted pulse stream
- July 29, 2024
- 5 replies
- 4787 views
Hi,
I want to make PWM stream with various duty, so I'm testing PWM with DMA using NUCLEO-G0B1RE and HAL library.
The first image shows weird pulse train. I set DMA buffer with [duty 1] * 8 + [duty 17] * 8 + [duty 5] * 8, but oscilloscope captures eight 1s, "nine" 17s and "seven" 5s. Left pane is screen of STM32CubeIDE Debugger.

I tested while debugging - if I change DMA buffer I can see results on-the-fly.
It looks like if I set more than 11 on DMA buffer, next PWM affected. I attached a short screen recording clip, please check it.
How can I get the exact PWM trains?
I also attached entire project files.
Note : I found code generation problem regarding TIM4 and DMA(https://community.st.com/t5/stm32cubeide-mcus/stm32cubeide-1-15-1-code-generation-problem/td-p/673440) so I modified HAL_TIM_PWM_MspInit()
