Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
void __attribute__((interrupt,no_auto_psv)) _IC1Interrupt(void)
{
    M_ToggleIO(LED2);
    ReadCapture1(&temp_edge);
    if(temp_edge > 0x6000 && temp_edge < 0x7000){
        edge_buffer[++temp_edge_index]= temp_edge;
        if(temp_edge_index > 120)temp_edge_index=50;
    }else{
        temp_edge_index = 0;
    }
    IC1_Clear_Intr_Status_Bit;
//    if(read_enable){
//        M_ToggleIO(LED3);
//        Interrupt_Count++;					//Number Input Capture counts
//        if(Int_flag == 0){
//            ReadCapture1(&timer_first_edge);	//Read the Time count for first capture of signal
//            Int_flag = 1;
//        }else if(Int_flag == 1){
//            ReadCapture1(&timer_second_edge);	//read the time count for second capture sgnal
//            Int_flag = 2;						//On two captured signals set the flag
//        }
        read_enable = 1;
//    }
			//Interrupt status clear
}
Exemplo n.º 3
0
avixDeclareISR(_IC1Interrupt, no_auto_psv){
    //        M_ToggleIO(LED3);
//    LED3 = C_ON;
    is_complete = 0;
    ReadCapture1(&edge_buffer_up[temp_edge_index_1++]);
    if (temp_edge_index_1 >= 200)temp_edge_index_1 = 0;

//    IC1_Clear_Intr_Status_Bit;
    IFS0bits.IC1IF = 0;
}