Hello --
I am attempting to code a couple pin change interrupts on two analog pins. MCU is a 1284P-PU @ 16MHz, Mighty-1284 Optiboot, pin mapping and enumerations depicted in attached JPEG. I have two Sharp digital IR sensors that are a bit sluggish on detecting when polled in the main loop. The sensors go LOW when an obstruction is detected, there are pull-up resistors on each, so each is configured as INPUT in void setup(). The output line of the sensors are wired to PA4 & PA5.
In reading the datasheet, I am under the impression that Port A pin change interrupts are enabled as PCIE0, Port B as PCIE1, Port C as PCIE2, and Port D as PCIE3. So, if wanting to enable pin change interrupts on the aforementioned pins, the following lines in setup() would work:
#define LEFTIR A5 //PA5, PCINT5
#define RIGHTIR A4 //PA4, PCINT4
void setup(){
pinMode(LEFTIR, INPUT);
pinMode(RIGHTIR, INPUT);
//enable Port A pin change interrupts, mask for specific pins
PCICR |= (1<<PCIE0); //enable group interrupts on PORTA PCINT[7:0]
PCMSK0 |= (1<<PCINT5); //mask to enable interrupt on A5 for LEFTIR
PCMSK0 |= (1<<PCINT4); //mask to enable interrupt on A4 for RIGHTIR
}
The ISR for Port A interrupts would be:
ISR (PCINT0_vect){
//do something quick
}
Thing is, over on Port C I have four pins accommodating wheel encoder outputs which also use pin change interrupts. It seems that in the library for the encoders PCINT0_vect is used for these encoders, giving errors on compile of sketch incorporating the IR sensors and the wheel encoders. Here is what I find in the library file:
ISR(PCINT0_vect)
{
// code for encoders
}
ISR(PCINT1_vect,ISR_ALIASOF(PCINT0_vect));
ISR(PCINT2_vect,ISR_ALIASOF(PCINT0_vect));
#ifdef PCINT3_vect
ISR(PCINT3_vect,ISR_ALIASOF(PCINT0_vect));
#endif
This is just a snippet out of the larger *.cpp file, attached below. I looked up ALIASOF in the avr-libc manual, and I think it means that the PCINT0_vect is referred to no matter the encoder pins reside on Ports A, B, C, or D. If this is true, is it possible to comment out the above quoted ALIASOF lines, and rename PCINT0_vect to PCINT2_vect, as my encoder pins are on Port C?
It would be hard to believe that the fix would be this easy. I am away from my work table at present, so will be delayed in checking this out. Any pointers from the forum to smooth this out for me is much appreciated.
Mark
PololuWheelEncoders_cpp.txt (6.69 KB)
PololuWheelEncoders_h.txt (3.15 KB)