AnsweredAssumed Answered

Generating trigg signals relative input capture

Question asked by grafstrom.daniel on May 27, 2015
Latest reply on Jun 3, 2015 by Clive One
Im trying to understand the input captre and output compare modes in the STM32 to fit my needs.
This code is supposed be used in a shotdetector for droplets for our test equipmnet.
Currently I'm using the STM32F3discovery board


So, I have 2 input channels and two ouput channels


ch0 - input capture - receives a pulse when droplet is supposed to be ejected (trigg signal)
ch1 - input capture - receives a pulse if a droplet is passing by my sensor (drop detector)
Ch3 - ouput compare - generates a pulse to a camera (about 10us pulse width) to capture the drip
ch4 - ouput compare - generates a pulse to a flash (about 100ns pulse width) to freese the drip in the picture.

The trigg-signal is also used to for a counter to know how may dots that was supposed to be ejected.
The detect signals is used for a counter to know how may dots that actually was ejected.


the input captue part is already finished and working. It's the output compare part that I have some questions about.

I would like to generate the the camera and flash pulses in relative the drop detetor signal. I also need to keep track of the time. Example, when i get the signal from the drop-detector (eg 23us after trigg signal on ch1) I would like to generate a trigg for the camera after 10us  and a flash signal after 20us. The logged times for the camera and flash wold be 33us for camera and 43us for the flash for that exact droplet (relative the trigg-signa from ch0l).

I have looked at the "one pulse mode" but it seems like it's clearing the clock.
Is it posssible to have a free-running clock (eg timer2) for the input catpture pins and use a second clock (eg timer 3) for the one pulse mode output pins? then it would be possible for me to captue the time between the two trigg-signals and then add an offset to generate the output signals.

Another question that popped up is when looking at reference code "stm32f3xx_hal_tim.c in STM32Cube_FW_F3_V1.1.0" it seems like the OPM is only supported on CH0 and CH1. But I can't find anything about this in the documentation.
Is it possible to use one pulse mode on channel 2 and 3 as well?

Or is there a better solution to the problem?

Thanks/
Daniel Grafström

Outcomes