Hardware PWM issues
Posted: Wed Aug 11, 2021 2:13 pm
Hello, everyone.
I have a little problem with the PWM on a STM32L475
It seems that an incoming UART message resets the PWM, but only if the PWM is currently in HighLevel.
Background. I have implemented the PWM once by interrupt and once by DMA request. The goal should be to set a GPIO port via the BSRR register. The PWM works with a frequency of 20 kHz and 100 ticks. On PORTD i have connected Mosfets to switch the Batteryvoltage in high and low level.
In the interrupt configuration the high level is set by a function in the config callback (update event) and the low level by a function in the callback of the capture compare register interrupt.
In the DMA variant two uint32_t variables are sent per DMA request, once at the update event to the BSRR register of the port and once at the channel event.
In both cases the TIM8 is used in the PWM configuration Interrupts high prio and in the DMA configuration TIM8_UP and TIM_8_CH4 on the DMA2 streams 1 and 2.
The USART1 DMA Streams are also on DMA2 but i have also change it to DMA1. Same result
In this picture below i change the dutycycle from 25% to 50% and send UART messages. you can see the first four periods are on low level and everything is fine. After that The message comes in at High level PWM and reset the Period ( red line)

Thanks!
I have a little problem with the PWM on a STM32L475
It seems that an incoming UART message resets the PWM, but only if the PWM is currently in HighLevel.
Background. I have implemented the PWM once by interrupt and once by DMA request. The goal should be to set a GPIO port via the BSRR register. The PWM works with a frequency of 20 kHz and 100 ticks. On PORTD i have connected Mosfets to switch the Batteryvoltage in high and low level.
In the interrupt configuration the high level is set by a function in the config callback (update event) and the low level by a function in the callback of the capture compare register interrupt.
In the DMA variant two uint32_t variables are sent per DMA request, once at the update event to the BSRR register of the port and once at the channel event.
In both cases the TIM8 is used in the PWM configuration Interrupts high prio and in the DMA configuration TIM8_UP and TIM_8_CH4 on the DMA2 streams 1 and 2.
The USART1 DMA Streams are also on DMA2 but i have also change it to DMA1. Same result
In this picture below i change the dutycycle from 25% to 50% and send UART messages. you can see the first four periods are on low level and everything is fine. After that The message comes in at High level PWM and reset the Period ( red line)

Thanks!