AnsweredAssumed Answered

Two Capture Components

Question asked by David Grimes on Dec 17, 2013
Latest reply on Jan 23, 2014 by Petr_H

I am working a project with QD4 and need to use two capture components for interrupts (both sharing TPM1.) The first capture is for a frequency signal 30 to 2000Hz, while the second is about half this speed (15-1000 Hz). I have configured both capture components to the same 65.384ms maximum. When I test with each capture independently they function correctly, both together give me erratic capture results. My ISR code is the same for both capture:



pin = CAPx_GetPinValue();

if (pin)


cap_x_high = time;




cap_x_low = time;




The signals are asynchronous, the erratic capture seems to occur when the interrupts occur close together. All the calcs are done outside of the ISR, with interrupts are disabled i.e.:


[do math]



I have also tried using an OverflowISR {overflow_counts++;} and NOT performing the Reset() for the timers, similar to:

cap_x_ = time - lasttime + (overflow_counts * TPM1MOD) ;


This doesn't work even when only one Capture is used. Where have I gone wrong?