cancel
Showing results for 
Search instead for 
Did you mean: 

PWM synch

manoritesameer
Associate II
Posted on July 25, 2014 at 22:38

How to Synch my PWM signal to the rising edge of an external signal. i.e The rising edge of my external signal should be on in synch with the leading ege of my PWM. 

I am using STM32F4 discovery board.

Thanks

#mow-my-lawn #stm32
4 REPLIES 4
Posted on July 25, 2014 at 23:23

Have a channel in Input Capture mode, latch the time base and interrupt, adjust count/period/pulse as required.

Some of the PWM Input mode examples also illustrate how to reset the timer count.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
manoritesameer
Associate II
Posted on July 27, 2014 at 00:55

Thanks Clive,

        if I reset the timer's counter when I  detect the rising edge by 

[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/Setting%20the%20UG%20bit%20in%20EGR%20register%20of%20the%20TIMER%201%20of%20STM32f4%20discovery&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=247]Setting the UG bit in EGR register 

would I be able to sync the rising edge of my PWM and the external trigger.

Thanks

Also is it possible to send a small example to the above method u have suggested.

Posted on July 27, 2014 at 02:42

You can write TIMx->CNT with any value you want. You'll have to experiment with your own signals (at whatever rate,width,periodicity they have)

Many things are possible, I'd be able to work on your problems if you work on mine.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
manoritesameer
Associate II
Posted on July 27, 2014 at 23:22

thanks clive, 

           sorry, I didnt mean to burden u with my work...

I tried to reset the UG bit on the rising edge (using EXTI ) of the external signal to synch the self generated PWM signal , yes it did work but with a delay of abt 800ns. Is there a way to reduce this error.

Thanks