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.

TMS320F28035-EP: HRCAP for long pulse widths

Part Number: TMS320F28035-EP

Tool/software:

We seem to have a problem using HRCAP function while capturing "long" pulse widths. By "long", I mean pulses where the HCCOUNTER overflows one or more times before an edge is detected.

Here is what I would have expected.

1. The HCCOUNTER would be reset on an edge (let's say a rising edge for this example).

2. The HCCOUNTER would begin to count at the SYSCLK rate (for our example)..

3. If no edge was detected before the HRCOUNTER overflowed, then a counter overflow interrupt would occur.

4. We would service the interrupt, increment a counter, and clear the interrupt flag.

5. For really long pulses, we have many HRCOUNTER overflows. We would count them as they occur.

6. When the edge (falling edge for our example occurs), we would service the falling interrupt, read the HCCAPCNTFALL1 register, clear the interrupt.

7. Take the number of overflows that occurred, multiply by 65536, then add HCCAPCNTFALL register to get total pulse width counts.

(See diagrams below)

The problem seems to be that we are counting two HCCOUNTER overflows on each overflow event, which makes our actual final count much larger than expected.

We are clearing the local HRCAP interrupt flags along with the PIE interrupt ACK in the ISR.

Does anyone have any experience with counting long pulse events with HRCAP ?

Before you say it, we cannot use ECAP because our PCBs are already make.

Thanks

  • Hi Gregory,

    Is the actual final count 

    ((2 (two HCCOUNTER overflows on each overflow event) * Overflow Count) * 66536) + HCCAPCNTFALL1 + 1?

    instead of expected

    (Overflow Count * 66536) + HCCAPCNTFALL1 + 1?

    Do you have any code snippet that you can share that is able to replicate this ?

    Best,

    Ryan Ma