SPRUIU1C July 2020 – February 2024 DRA821U , DRA821U-Q1
// Code snippet for CAP mode Absolute Time, Rising & Falling edge triggers
// Run Time ( e.g. CEVT4 triggered ISR call)
//==========================================
TSt1 = ECAPxRegs.CAP1; // Fetch Time-Stamp captured at t1
TSt2 = ECAPxRegs.CAP2; // Fetch Time-Stamp captured at t2
TSt3 = ECAPxRegs.CAP3; // Fetch Time-Stamp captured at t3
TSt4 = ECAPxRegs.CAP4; // Fetch Time-Stamp captured at t4
Period1 = TSt3-TSt1; // Calculate 1st period
DutyOnTime1 = TSt2-TSt1; // Calculate On time
DutyOffTime1 = TSt3-TSt2; // Calculate Off time