itinerantAlien
Member
Hi.
I'm trying to port some code I wrote for an Arduino Mega2560 (in the Arduino IDE) to a Teensy 3.2 (using Teensyduino) but I'm stuck on how to do the Teensy equivalent of this line that clears the external interrupt's status flag:
EIFR=bit(INTF5) // INTF5 is the bit in EIFR relating to interrupt 1 (on pin 3!) of the Arduino Mega2560
Given how fruitless my searches have been, I take it not many people clear this flag manually (or it's so obvious to everybody else how to do it that they haven't had to ask
I read in Nick Gammon's excellent article on interrupts (where I got that line of code from) that it should be done immediately prior to enabling the interrupt so that your ISR doesn't immediately fire after the interrupt is enabled due to a previously flagged interrupt instance (I periodically disable/re-enable the interrupt on the pin.) Then when trying to find out how to do it on the Teensy I came across Paul's article on interrupts (which seems to only relate to AVR Teensys?) which also refers to resetting the interrupt flag before setting the interrupt mask.
For completeness, these are all the lines of code that relate to managing the external interrupt that I'm porting from the Mega2560 to the Teensy 3.2:
EIFR=bit(INTF5);
attachInterrupt(1, ISR_Rx, FALLING);
detachInterrupt(1);
I believe the other two lines will change to the following (staying with pin 3):
attachInterrupt(3, ISR_Rx, FALLING);
detachInterrupt(3);
All help will be much appreciated. Thanks for your time.
I'm trying to port some code I wrote for an Arduino Mega2560 (in the Arduino IDE) to a Teensy 3.2 (using Teensyduino) but I'm stuck on how to do the Teensy equivalent of this line that clears the external interrupt's status flag:
EIFR=bit(INTF5) // INTF5 is the bit in EIFR relating to interrupt 1 (on pin 3!) of the Arduino Mega2560
Given how fruitless my searches have been, I take it not many people clear this flag manually (or it's so obvious to everybody else how to do it that they haven't had to ask
I read in Nick Gammon's excellent article on interrupts (where I got that line of code from) that it should be done immediately prior to enabling the interrupt so that your ISR doesn't immediately fire after the interrupt is enabled due to a previously flagged interrupt instance (I periodically disable/re-enable the interrupt on the pin.) Then when trying to find out how to do it on the Teensy I came across Paul's article on interrupts (which seems to only relate to AVR Teensys?) which also refers to resetting the interrupt flag before setting the interrupt mask.
For completeness, these are all the lines of code that relate to managing the external interrupt that I'm porting from the Mega2560 to the Teensy 3.2:
EIFR=bit(INTF5);
attachInterrupt(1, ISR_Rx, FALLING);
detachInterrupt(1);
I believe the other two lines will change to the following (staying with pin 3):
attachInterrupt(3, ISR_Rx, FALLING);
detachInterrupt(3);
All help will be much appreciated. Thanks for your time.