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
Hello Clive,
I'm replacing the functions you've used for the F4 library's functions, so I can better understand what you meant to do.
But there is one thing I can't still figure it out.
Why did you define the "TIM2_IRQHandler(void)" function if you din't even call it in the main part?
Do I have to call it just before the "while(1)" cycle?
Thank you, Mara
It's an Interrupt, it's called by the processor when the TIM2 Update Interrupt asserts. The NVIC/TIM configuration enable this, and the vector table of interrupt handlers are listed in startup_stm32f4xx.s direct execution to the routine.
It will be called outside the flow of regular code, you don't need to explicitly call it. This is how interrupts work. Please refer to Computer Science and Micro-Controller texts if you need foundational understanding.
I'd recommend one of Joseph Yiu's books on the Cortex-Mx series parts, and there are of course ARM's Technical Reference Manuals (TRM) which describe the cores in significant detail.