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.

External timer input capture maximum frequency

Hi gurus,

Please forgive the simple question - I'm trying to wrap my head around this.

I have a (fast) clock coming from an external source. I want to measure its frequency. The thinking is to feed that clock into an external capture timer pin, eg TACLK or TA0, for some fixed period of time (eg 50 ms). Then take a look at how much the counter register has incremented.  (And probably add an interrupt to count overflows.)

What I cannot quite work out is the maximum input frequency the TACLK or TA0 pin will handle. For example, on the MSP430x22x2 datasheet, it says:

Timer_A Clock Frequency  (TACLK):  16 MHz max

Timer_A Capture Timing (TA0): 20 ns min

A 20 ns period corresponds to 50 MHz.

Am I correct in believing that 20 ns (TA0) is only for a single edge, not a clock per-se?  So in my case, where I want an external clock to increment an asynchronous counter, I have to use TACLK which is limited to 16 MHz?

I'd like to count up faster if I could - 50 MHz would be nice.

Thanks.

  • Hi Frank,

    Unfortunately, counting pulses or measuring pulse widths etc etc on a signal faster than 16MHz is impossible on the x2xx parts.

    Anything faster than even 1 MHz is prohibitively difficult.

    Looks like the timer module can make asynchronous captures at a rate up to 50 MHz, but it can't count them and neither can the CPU because it can run only at 16MHz.

    You'll probably need to use an external IC counter or divider if you want to use the MSP430.  Also there are other MCUs better suited for measuring frequencies.

    Jeff

  • Such a shame. PICs seem to be the default standard for this - they have an asychronous  counter that can be externally clocked at around 40 MHz. Being async it doesn't matter what the CPU frequency is. I'd like to find another MCU with this kind of feature but there's nothing I've seen. Which is a real shame. (Unless you're a microchip shareholder of course.)

     

  • Frank,

    I have to correct myself regarding the 1 to 16 MHz comment.  It's not prohibitively difficult to measure those frequencies with the x2xx.

    Much like the PIC, you can clock the counter ("timer") via an external signal TACLK / TBCLK.  Unfortunately, TI won't spec it higher than Fmax (16MHz for the x2xx).

    So as long as one timer is counting time against a known reference (say a 32kHz quartz crystal), then you could use a second timer clocked by the external <16MHz clock to measure the external clock's frequency.

    But still no luck for frequencies above 16MHz.  (The x5xx series lets you measure up to 32MHz via the XT2 mechanism and up to 25MHz via the TACLK / TBCLK mechanism.)

    Jeff

  • the 20ns timing is the minimum required pulse width to have a capture event recognized. On 25MHz this means 50% duty cycle, on lower frequencies the duty cycle of the signal may be more unbalanced. Yet the maximum frequency is the maximum frequency.

    You can, however, oincrease thsi by addign an external divider. It will only allow frequency detection in steps of 2 or 4, but then this will too ensure 50% duty cycle. A simple TTL chip will extend the maximum frequency to up to 128MHz (/8 HCT counter)

    I haven't tested whether the maximum frequency applies to the input signal or the used clock (after the divider) as long as the pulse width is maintained. So maybe even with a maximum clock frequency of 16MHz it could be possible to measure 25MHz a long as the pulse length is 20ns (50% duty cycle) when using a clock input divider of 2. But that's just a guess. On the 54xx i tmakes no difference anyway.

    Keep in mind that clocking the timers asynchroneously to the MCLK requires additional precautions when e.g. reading the TAR register.

  • Thanks very much both of you for your helpful comments. I wasn't aware the 54xx family could handle higher external signals - I'll look into that. At around 30 MHz it starts becoming interesting.

     

  • frank van hooft said:
    I wasn't aware the 54xx family could handle higher external signals

    Well, it's no real surprise.

    The port logic and the hardware modules as well as the production process are identical for the 54xx and the 54xxA. The main difference is the CPU core and voltage handling, which got improved (and of course some enhancements/bugfixes of some of the hardware modules such as CRC.

    The limiting factor is the minimum pulse with of 20ns which gives 25MHz on 50% duty cycle. On both series.

    Also, DCO and crystal logic are able to handle _much_ higher frequencies, but you'll have to scale them down to 18 or 25MHz before using them with any of the hardware modules. But well, if you know that 1 count on TAR is two (scaled down) signal pulses on XT2, you have full frequency, just not full resolution of 1 pulse.

    The only thing tha tmight be tricky is the handling of XT2OFFG, but IIRC this check is disabled if an external digital source is configured for the XT2 input. You should check the users guide and datasheet before trying.

**Attention** This is a public forum