cancel
Showing results for 
Search instead for 
Did you mean: 

Timers Synchronization

keaven
Associate II
Posted on November 02, 2015 at 19:29

I need to use the timer synchronization in my STM32F7 project.  The purpose of the timers are to provide the necessary signals to a CCD sensor.  I have a shutter pulse (T5-CH4) and a pixel clock (T4-CH2).  I am also using another channel of the same timer as the pixel clock for the ADC trigger (T4-CH4).

The frequencies are the following: Shutter is 20 Hz and pixel clock/ADC trigger are 60 KHz.

My requirements are:  

- the shutter is a variable PWM with the falling edge used as start event

- the pixel clock must have his rising edge synchronized with the falling edge of the shutter and has to be present all the time.

- The ADC trigger is the inverse of the pixel clock but must be start on the falling edge of the shutter.  This clock is present for the length on the acquisition.  It is stopped once the DMA transfer is done.

Now, the problem I have now is that I can have a bad pixel synchronization since I didn't sync anything and the pixel clock is free running and the ADC trigger is misplaced. Finally, I am enabling the ADC trigger on the pulse completion callback of the shutter.

Before determining the required configuration, first are the channels of the same timer synchronous to each other.  Here, in my application the pixel clock is always running but the ADC trigger is enable when I need to convert the signal.  If I enable the ADC trigger at a time X  will it be perfectly synchronous with his paired channel but inverted?

If so that will means I will only need to synchronize the falling edge of the shutter with the rising edge of the pixel clock?  If not I will need to synchronize all three timers/channels together.

I think we can only use the rising edge for synchronization if I read correctly.  So this mean I will need another timer to start everyone together right?

Hope you have all the information needed to answer.

#synchronization #stm32f7 #timer
6 REPLIES 6
Posted on November 02, 2015 at 20:00

Each timer has a single timebase counter, thus all channels are synchronous to this count/phase

You can set timers to synchronize/reset against another timer, if you want to synchronize multiple timers you'd want to find the configuration/setting to use a common one. I would probably want to use all timers on a common APB, or make sure APB1/APB2 clock at the same rate. I expect they mux off the same divider chain taps.

You have no visibility into the prescaler.

I'm not offering to wade into your specifications/requirements.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
tba10596
Associate II
Posted on November 02, 2015 at 20:18

Timers can be synchronized - see ''18.3.15 Timer synchronization'' in the RM0090 Reference Manual. I am not sure if there is example code available to do the synchronization.

Regards,

Todd Anderson

keaven
Associate II
Posted on November 04, 2015 at 21:33

I progress quite well in my synchronization but I have the following question.

I want to use the GATE mode but I am not able to get it worked.

1- Can you tell me if the synchronization feature works only on channel 1 of each timer?

2- What event I am using on the master to tell to clock the slave signal on master low level?

Thank you
Posted on November 04, 2015 at 23:01

> I progress quite well in my synchronization but I have the following question.

> I want to use the GATE mode but I am not able to get it worked.

That doesn't sound ''quite well'' to me.

Start with thorough reading of the timer chapter in RM.

> 1- Can you tell me if the synchronization feature works only on channel 1 of each timer?

''Synchronization'' does not work on any channel, it works on the counter (TIMx_CNT).

> 2- What event I am using on the master to tell to clock the slave signal on master low level?

What do you mean by ''master low level''?

The selection of events to be used as TRGO is given by TIMx_CR2.MMS - read its description.

JW

keaven
Associate II
Posted on November 05, 2015 at 15:35

I did read the RM but I don't understand some part of it and which I will go through again.

I mean by ''master low level'' : a master timer when his output level is low.  I wanted to use  a master PWM 20 Hz signal as XOR signal for a slave timer 3 MHz that is active on master low level.

Thank you for specifying me the control is on TIMx_CNT.  It means that if I am synchronizing a timer with another it will have an effect all the channels of this timer rather than only one channel.

keaven
Associate II
Posted on November 06, 2015 at 20:51

Quick note to let you know that I got my thing running.   I had to use to 2 other timers. One for starting up everyone and another to split 2 channels used of a same timer.  So I ended up with a synchronization reference signal, a shutter signal for my camera, a pixel clock and my ADC trigger all synchronous.

I loose some time on some options that we can use in STM32F7 and not on STM32F4.  The combined reset and trigger doesn't exist on a STM32F4.  Finally, we cannot have a trigger option with a gated signal.  Well I didn't find how to do it.

Once again thank you all for the advice/pointers it help me out a lot with the registry description in the reference manual.