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(); }
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 I2C ISR Flag interrupt flag PIR1bits.SSPIF = 0; // call the handler i2c_master_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(); }
interrupt #else #pragma code #pragma interrupt InterruptHandlerHigh #endif void InterruptHandlerHigh() { // check to see if we have an I2C interrupt if (PIR1bits.SSPIF) { PORTBbits.RB5 = 1; // clear the interrupt flag PIR1bits.SSPIF = 0; // call the handler #ifdef MASTERPIC i2c_master_handler(); #else i2c_slave_handler(); #endif PORTBbits.RB5 = 0; } #ifdef SENSORPIC if (PIR3bits.SSP2IF) { PIR3bits.SSP2IF = 0; i2c2_master_handler(); } #endif SleepIfOkay(); }
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(); }