cancel
Showing results for 
Search instead for 
Did you mean: 

Pulse Width Measurement

mvi
Associate II
Posted on May 11, 2008 at 08:32

Pulse Width Measurement

3 REPLIES 3
mvi
Associate II
Posted on May 17, 2011 at 12:34

Hello!

I want to measure the width of a pulse from an edge to edge. i.e. From falling edge to rising edge and rising edge to next falling edge continuously. I'm thinking that a TIMx channel would be able to do it.

What I have in mind is if the TIMx channel can trigger an interrupt on each edge (rising/falling), then within the ISR I can start/stop the counter and read the counter value to obtain a measurement.

Can someone tell me what mode and such should be the TIMx put into? A link into reference material for me to read into would be great as well...

Cheers!

-Mad D

[ This message was edited by: mvi on 09-05-2008 19:19 ]

mvi
Associate II
Posted on May 17, 2011 at 12:34

No replies... Hehe...

Well so far I havent found a way to get this done...

But I was thinking maybe I could use the TIM1_CH3 input in IC mode and use it as a falling edge trigger producing a interrupt. Then in the ISR I could maybe start TIM2 as a simple Up Counter with a ARR val set to what I need. This would produce an interrupt at rolling or update so that I can sample the input signal.

The whole purpose of this is to create a software USART receiver. If someone has a better solution please let me know.

Cheers

-Mad D

jj
Associate II
Posted on May 17, 2011 at 12:34

Seems as - if like us - you do NOT have a hardware base with which

to experiment. Our boards are ''in process'' - will have shortly.

Using another ARM - with ''edge'' triggered interrupts - we were able to

measure pulse widths with great precision. Within our interrupts - we

''confirmed'' that the signal was stable (thus valid) and further determined the pulse's polarity. We used a 2nd ARM as a known-good pulse generator - adjustable via a small Lcd. This immensely aided our software development - providing ''instant'' feedback as we ''played'' with the various mode/function settings - even discovering ''undocumented'' capabilities... I personally learn best, more memorably this way.

Software Uarts do better when you confirm the validity of your Start Pulse, especially. (you don't want a noise burst to be seen as data) As STM32s have multiple Uarts - yours must be a communication intensive Ap. It may serve you to ''multiplex'' the SPI or I2C functions - which provide higher speed transfers. There are methods to extend their distance.