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.

NHET HR capture on multiple pins?

I've been circling the RM42 TRM (SPNU596A) sec 17.2.5.3/.4 and the Forum, and I haven't been able to answer this.


Can I use the N2HET to perform input capture on multiple (e.g. 4x) separate pins in High Resolution?

For each pin, the input frequency is fairly low (a few kHz), but I need high precision (at least 16MHz) in the captured timestamps, and I need them to have the same timebase (i.e. comparable to one another). The inputs are not correlated, so it is entirely possible that more than one pin will have a (single) edge within a single LRP.

There's nothing exotic here -- this is something done routinely with "traditional" timers (given 4x CCRs and a fast-enough clock).

What I've read seems to wander between "one HR capture per LRP" and "one HR capture per pin per LRP", where the distinction between these two is critical for my purposes.

  • Bruce,

    If you see a sentence in the TRM that is ambiguous - please (we appreciate but you don't have to) submit a doc feedback so we can get it into the list to correct. There is a link on the bottom of each PDF page (Submit Doc Feedback) that you can use for this purpose.

    Each pin has a hardware HR capture/compare register that is 7 bits. It's a combination of the hardware capture/compare and the software counter on the upper 25 bits that gives you 32-bit capture compare ability with resolution of 1 hi-res clock.

    The limitation is that each *pin* can only have one capture or compare event per loop resolution period. Think about the loop resolution period as the 'service time' for a single hardware capture/compare structure by an external CPU. If there are 2 events between the service time - one will get lost.

    So yes you can do what you want to do.

    In addition we have 3 sharing modes that let you apply two of these 7 bit capture/compare hardware counters to the same physical pin.
    You use the hardware timer from the 'odd' pin to also operate on the 'even' pin when you turn sharing on.
    For example, if you turn on HRSHARE for pins 0/1, then the physical pin 0 signal is routed to both the hardware for pin 0 and pin 1 as expressed by the PIN=# field in the HET instruction.

    If you turn on this HRSHARE you could actually have code that does a period measurement (rise to rise) on pin 0 and a duty measurement (rise to fall) on pin 1, but in reality they would both be measuring the signal coming in on N2HET[0] because you turned on HRSHARE.

    For output compares, the analogous modes are AND and OR SHARE where two hardware output compares are AND'd or OR'd together onto the same N2HET pin.

    From your description - I don't think you need any of these sharing modes but want to explain that they exist.