I tried to make a quick fix to increase the coverage of our IR sensors by quickly adding a second interrupt and third interrupt. I knew the way I did it wasn't right, but it mostly worked enough. I was wondering what I would have to do to properly add more interrupts to the the IR code. I don't like wiring multiple sensors in parallel, because it looks like if the sensors receive signals at different times, their output pulses will interfere.
Here is what I did:
Code:
#ifdef ENABLE_INT_3
if(Port_B_Delta & 0x10) // did external interrupt 3 change state?
{
IR_Sensor_ISR(Port_B & 0x10 ? 1 : 0); // call the interrupt 3 handler (in interrupts.c or encoder.c)
}
#endif
#ifdef ENABLE_INT_4
if(Port_B_Delta & 0x20) // did external interrupt 4 change state?
{
IR_Sensor_ISR(Port_B & 0x20 ? 1 : 0);//Int_4_ISR(Port_B & 0x20 ? 1 : 0); // call the interrupt 4 handler (in interrupts.c or encoder.c)
}
#endif
#ifdef ENABLE_INT_5
if(Port_B_Delta & 0x40) // did external interrupt 5 change state?
{
IR_Sensor_ISR(Port_B & 0x40 ? 1 : 0);//Int_5_ISR(Port_B & 0x40 ? 1 : 0); // call the interrupt 5 handler (in interrupts.c or encoder.c)
}
Thanks in advance!