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.

Use timer to measure PWM counts?

Other Parts Discussed in Thread: MSP430F6720

Hi folks,

I am having some trouble measuring PWM counts, wish some of you could give me a hand. The PWM signal (RSSI of xbee) runs at 12MHz, depending on strength of signal, the number of pulse counts varies. My setup is: MSP430F6720, PWM signal is fed into TACLK (P3.2), used it as source of timer. I then read number of counts in certain period of time, say 400 micro second.

Somehow this setup doesn't work. TA3R always reads 0.My code seems to be OK:

 // Bring RSSI from xbee into TACLK/P3.2, refer to port map.
 P3SEL |= BIT2;
 P3DIR &= ~BIT2; 

TA3CTL = MC_2 | TACLR;          // Default to external clock, continuous mode
 delay_us(400);                            // Delay 400 micro seconds / two duty cycles
 TA3CTL &= ~MC_3;                  // Stop TA3
 count = TA3R;
 TA3CTL |= TACLR;

Is this a correct way of doing this sort task? or I would better off using capturing mode? Many thanks.

  • The code looks god so far. It’s surprising that all timers share the same external input clock on this MSP, as it prevents cascading, but well – it should work.
    Now the 400µs could be wrong, or you have 0% or 100% duty cycle on the PWM, in which case you don’t have any clock transitions and the timer cannot count anything.

    However, if you have a variable pulse frequency, then you don’t have a PWM (as PWM is Pulse Width Modulation, fixed frequency with variable pulse width) but rather a V/F signal (voltage – or value – modulated frequency) In this case you should indeed see counts – unless RSSI is 0 and no pulses are generated..

    What happens if you don’t stop the timer but just read the count and show it. And maybe apply manual pulses to the pin?

  • Hi Jens-Michael Gross,

    Thanks for reading and going over my post. I should have updated it earlier.


    It turned out the signal I am dealing with, RSSI of xbee, is just a typical PWM. Within each duty cycle (200uS), there is only one falling and rising edge. The width can be easily measured by connecting it to an interrupt enabled GPIO or the capture mode of a timer.

    The manual of xbee  (page 97-98) is written in such a way that it made me believe it is in fact some sort of V/F signal even it says it is PWM. My understanding was that, even the frequency is fixed at 12MHz, the number of pules that are running at 12MHz will vary within each duty cycle (200uS). So I should be able to measure the number of counts by using it as source of timer. After much struggling,  I hooked it up to an oscilloscope, and found the problem.

  • Can you mention how you are using the time capturing option, as i not get it how to set input for that.

**Attention** This is a public forum