This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to measure the pulse width of a signal that is input to the MCU

Other Parts Discussed in Thread: MSP430F5635

Hi

I am using MSP430F5635 MCU .

My requirement is to do an activity if the pulse width of a signal that is input to the MCU is greater than 50 msec.

How do I measure the pulse width of an incoming GPIO signal from software ?

Thanks

Jenitta

  • Besides a plain software solution (constantly check the port pin and note down the moments of state change) you can use the hardwar etimers. The timer CCR units can capture the current timer count at the moment of a signal edge. If you use two CCR units, you can capture the timer counts at both edges and the count difference is directly proportional to the duration of the pulse.
    The timer clock frequency (and also the resolution) has to be configured so that th emaximum pulse length does not exceed 65535 timer ticks. Well, for 10ms maximum pulsewidth, a 1MHz timer clock is okay and teh difference in tiemr counts between the two signal edges directly gives you the pulsewidth in µs.

    YOu can trigge ran interrupt with the second edge, so that the software gets informed that a pulse was received and its duration can be calculated.

**Attention** This is a public forum