Esempio n. 1
0
interrupt
#else
#pragma code
#pragma interrupt InterruptHandlerHigh
#endif

void InterruptHandlerHigh() {
    // We need to check the interrupt flag of each enabled high-priority interrupt to
    // see which device generated this interrupt.  Then we can call the correct handler.

    // check to see if we have an I2C interrupt
    if (PIR1bits.SSPIF) {
        // clear the interrupt flag
        PIR1bits.SSPIF = 0;
        // call the handler
        i2c_int_handler();
    }

    // check to see if we have an interrupt on timer 0
    if (INTCONbits.TMR0IF) {
        INTCONbits.TMR0IF = 0; // clear this interrupt flag
        // call whatever handler you want (this is "user" defined)
        timer0_int_handler();
    }

    // The *last* thing I do here is check to see if we can
    // allow the processor to go to sleep
    // This code *DEPENDS* on the code in messages.c being
    // initialized using "init_queues()" -- if you aren't using
    // this, then you shouldn't have this call here
    SleepIfOkay();
}
Esempio n. 2
0
interrupt low_priority
#else
#pragma code
#pragma interruptlow InterruptHandlerLow
#endif
void InterruptHandlerLow() {
    // check to see if we have an interrupt on timer 0
    if (INTCONbits.TMR0IF) {
        INTCONbits.TMR0IF = 0; // clear this interrupt flag
        // call whatever handler you want (this is "user" defined)
        timer0_int_handler();
    }

    // check to see if we have an interrupt on timer 1
    if (PIR1bits.TMR1IF) {
        PIR1bits.TMR1IF = 0; //clear interrupt flag
        timer1_int_handler();
    }

    // check to see if we have an interrupt on USART RX
    if (PIR1bits.RCIF) {
//        DEBUG_ON(UART_RX);
        PIR1bits.RCIF = 0; //clear interrupt flag
        uart_recv_int_handler();
//        DEBUG_OFF(UART_RX);
    }
    
    // check to see if we have an interrupt on USART TX
    if (PIR1bits.TXIF && PIE1bits.TXIE) {
//        DEBUG_ON(UART_TX);
        uart_trans_int_handler();
//        DEBUG_OFF(UART_TX);
    }
}
Esempio n. 3
0
interrupt
#else
#pragma code
#pragma interrupt InterruptHandlerHigh
#endif
void InterruptHandlerHigh() {
    // We need to check the interrupt flag of each enabled high-priority interrupt to
    // see which device generated this interrupt.  Then we can call the correct handler.

    // check to see if we have an I2C interrupt
    if (PIR1bits.SSPIF) {
        // clear the interrupt flag
        PIR1bits.SSPIF = 0;        
        // call the handler
        i2c_master_handler();
    }

    // check to see if we have an interrupt on timer 0
    if (INTCONbits.TMR0IF) {
        INTCONbits.TMR0IF = 0; // clear this interrupt flag
        // call whatever handler you want (this is "user" defined)
        timer0_int_handler();

    }

    if(PIR1bits.ADIF) //ADC conversion complete
    {
        PIR1bits.ADIF = 0; //clear it
        adc_int_handler();

    }

     if (PIR1bits.RCIF)
     {
         #if ENABLE_GPIO
         MAIN_THREAD = 0;
         UART_RECEIVE_THREAD = 1;
         #endif
         uart_recv_int_handler();

         

     }
    // here is where you would check other interrupt flags.

    // The *last* thing I do here is check to see if we can
    // allow the processor to go to sleep
    // This code *DEPENDS* on the code in messages.c being
    // initialized using "init_queues()" -- if you aren't using
    // this, then you shouldn't have this call here
    SleepIfOkay();
}
Esempio n. 4
0
interrupt low_priority
#else
#pragma code
#pragma interruptlow InterruptHandlerLow
#endif
void InterruptHandlerLow() {

    // check to see if we have an interrupt on timer 0
    if (INTCONbits.TMR0IF) {
        INTCONbits.TMR0IF = 0; // clear this interrupt flag
        timer0_int_handler();
    }

    // check if A/D conversion has ended
    if(PIR1bits.ADIF){
        PIR1bits.ADIF=0;
        ADC_int_handler();
    }
    
    // check to see if we have an interrupt on USART TX
    if (PIR1bits.TXIF) {
        PIR1bits.TXIF = 0;
        uart_send_int_handler();
    }
    // check to see if we have an interrupt on USART RX
    if (PIR1bits.RCIF) {
        PIR1bits.RCIF = 0; //clear interrupt flag
        uart_recv_int_handler();
    }

    // Change on PORTB
    if(INTCONbits.RBIF) {
        INTCONbits.RBIF = 0;
        // Rising edge on RB5
        if(LATBbits.LB5 == 0 && PORTBbits.RB5 == 1) {
            encoder_int_handler();
        }
        LATBbits.LB5 = PORTBbits.RB5;
    }
/*    // check to see if we have an interrupt on timer 1
    if (PIR1bits.TMR1IF) {
        PIR1bits.TMR1IF = 0; //clear interrupt flag
        timer1_int_handler();
    } */
}