I have a problem with PWM generation.
I have my own PCB with the uC STM32F429IIH. I am trying to configure the PWM in TIM3 channel 1. My clock frecuency is 180 MHz and APB1 Timer Clock is 90 MHz.
I use STM32CubeMX to initialize the board. In the timer 3, I configure the prescaler with value 5 and the period with value 4095, so my PWM signal frecuency must be 3.66 KHz. Furthermore, I configure a fixed pulse of 500. In the main function I call the function HAL_TIM_PWM_Start to start the PWM signal.
In an oscilloscope I observe that the frequency is correct but the duty cycle is unstable. Most of the time, duty cycle varies between 12.2% and 12.3% but sometimes it downs till 11.6%. It seems that in some cycles the duty cycle changes too much.
I have tried to change the duty cycle, the prescaler and the period, but I always have the same problem: the duty cycle is unstable. I have tried with another oscilloscope too.
Does anyone know why the duty cycle varies so much? Am I configuring something wrong?
Thanks for your help.