cancel
Showing results for 
Search instead for 
Did you mean: 

Precise Timer Project

Ruben Sotolongo
Associate
Posted on October 16, 2017 at 16:47

Hey guys I'm new to the st family and I have a project I need some help with. I have two square wave pulses that come into the micro and i need to be able to measure the time in between the fall of the first pulse and rise of the second, the thing is that this time is as short as 400ns (200ns on a later project) and I have no earthly idea how to reliably measure that. Also I would need to get one or two adc samples (sample and hold?) somewhere in the pulse just to confirm that it went below a certain voltage.

I am a total rookie and would prefer to use the arduino IDE but i do know C code if that works better. I need help on getting started on this.

The chip I'm using is the STM32F103C8 and ive set it up with an usb boot loader and hooked it up to the Arduino IDE.

1 REPLY 1
S.Ma
Principal
Posted on October 16, 2017 at 18:34

Use a Timer with 4 channels, use channel 1 and 2 to capture and optionally trigger the timer to sample the rise/fall time.

The channel 3 and 4 can be used to generate pulse/edges on a GPIO which can be routed to the ADC trigger pin. You can then control the precise timing the ADC start sampling respective to the kick in of the timer. This will make a well assisted HW solution. If the timer runs at 10Mhz, you get 100ns per step. Make the timer max value so that it is the minimum needed (to rearm it for the next event asap).