Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 276 → Rev 277

/PIC Stuff/PICX_16F1829_Controller/INTERRUPTS.c
3,6 → 3,7
#include "I2C1.h"
#include "I2C2.h"
#include "IO.h"
#include "CPS.h"
 
void Interrupt_Init() {
 
20,6 → 21,7
}
 
void interrupt InterruptHandler(void) {
uint8_t tmr0_rollover = 0;
// 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.
 
34,9 → 36,16
// return;
// }
 
 
// Check to see if we have an interrupt on Timer 0 (CPS)
if (INTCONbits.TMR0IF) {
CPS_Timer_0_Interrupt_Handler();
INTCONbits.TMR0IF = 0;
return;
}
// Check to see if we have an I2C1 interrupt
if (PIR1bits.SSP1IF) {
 
// Call the handler
I2C1_Interrupt_Handler();
 
43,7 → 52,9
// Clear the interrupt flag
PIR1bits.SSP1IF = 0;
 
return;
if (INTCONbits.TMR0IF) {
tmr0_rollover = 1;
}
}
 
// Check to see if we have an I2C2 interrupt
54,9 → 65,19
// Clear the interrupt flag
PIR4bits.SSP2IF = 0;
 
return;
if (INTCONbits.TMR0IF) {
tmr0_rollover = 1;
}
}
 
 
// If Timer 0 rolls over while servicing another interrupt handler,
// reset the timers as the sample will be inaccurate.
if (tmr0_rollover) {
INTCONbits.TMR0IF = 0;
CPS_Reset();
}
 
// // Check to see if we have an IO interrupt
// if (INTCONbits.IOCIF) {
// // Call the handler