void __ISR(_INPUT_CAPTURE_1_VECTOR) INT_IC1_Handler(void) { mIC1ClearIntFlag(); //Read captured timer values if(mIC1CaptureReady()) { IC1_CT_Rise = mIC1ReadCapture(); IC1_CT_Fall = mIC1ReadCapture(); } //Determine period if(IC1_CT_Rise > IC1_CT_Fall) period1 = (IC1_CT_Fall + PER_REG) - IC1_CT_Rise; else period1 = IC1_CT_Fall - IC1_CT_Rise; //Correct period if out of range if(period1 > THRO_H - 2) period1 = THRO_H; else if(period1 < THRO_L + 5) period1 = THRO_L; //Turn period into Throttle percentage 0.0 thru 100.0% IC_THRO = ((period1 - THRO_L) / (THRO_H-THRO_L)) * 100.0; ReadCapture1(garbage); //clear any remaining capture values }
// Input Capture Event Interrupt // On input capture this interrupt will get the time taken to charge the capacitor // and signal the capacitor thread to continue void __ISR(_INPUT_CAPTURE_1_VECTOR, ipl2) IC1Handler(void) { charge_time = mIC1ReadCapture(); CloseCapture1(); mIC1ClearIntFlag(); charged = 1; }
//===================== Capture ISR =============== // void __ISR(_INPUT_CAPTURE_1_VECTOR, ipl3) C1Handler(void) { capture1 = mIC1ReadCapture(); //calculates the capacitance cap=-1*((float)capture1/(pow(10,-9)*R*TCLK))*pow(log(1-1.2/3.24),-1); // clear the timer interrupt flag mIC1ClearIntFlag(); }