2014-03-14 10:33 PM
Respected Sir,
I am new and dont have much exposure to ST microcontrollers and i am planning to use STM32F051 microcontroller in one of my projects,the project requires me to generate with a square waveform having a waveshape as shown in the attached .bmp file and with frequency ranging from 200Khz to 800Khz with duty cycle varying from 1% to 50%, the highest frequency that can be generated by me using the timer interrupts and GPIO toggling technique is 155Khz,while using the PWM module i can generate the frequency but cant match the waveshape,please guide me on this issue,Any Help and pointers is highly appreciated.Thanks and Regards,Girish2014-03-15 05:34 AM
Well you're going to want to avoid interrupts in >100KHz range, as the processor is going to saturate.
If you needed 50/50 duty you could generate two phase shifted signals from a single timer. This can be done with Toogle mode, and inferring phase with different TIMX->CCRx offsets. ie a Quadrature output. Your example probably needs two timers, with the phase relationship set using different TIMx->CNT values. You might be able to use some slave mode settings to do this, but you're going to have to read and understand the documentation. You might also be able to use TIM->DMA->GPIO to drive pins with a pattern buffer too.