Hello,
I'm tyring to program a STM32F4 (with ARM F4) board to generate a sinusoidal PWM, that is a sequence of pulses with variable width that, once filtered by a LPF, gives a sinusoid.
I was told the best way to get it is by generating a sequence of single pulses synchronized to timer by interrupts.
I've tried several solutions but I'm not good at managing interrupts.
Do you have any idea how to achieve this goal? Can you attach a piece of code where it's explained how to do it?
Thanks in advance! ;)
Mara
Hi Mara,
have a look at the "stm32f4xx_hal_tim.h". I can't see that you are starting the timer. Try one of the functions in the mentioned header file e.g. "HAL_TIM_Base_Start_IT". The function "HAL_TIM_Base_Start_DMA" might also be interesting for you. Try to find out which one of the functions you need as I'm also not as familiar with the HAL of ST.
Also, as Clive said, be careful with the frequency you want to run the timer with and with choosing the prescaler. The clock the timers are running with is not always the system clock. In ST's datasheets you always find an "block diagram" of the controller. In that picture you can see the maximum possible frequency the timer can run with, which is also most likely the frequency that will be configured for the timer. Good luck!
Regards, Niclas