I'm trying to get a pin change interrupt on an Attiny2313 to work but i'm stuck, the interrupt is not triggering.
I'm using the following code in main()
:
GIMSK |= (1 << PCIE2);
PCMSK2 |= (1 << PCINT13) | (1 << PCINT14) | (1 << PCINT15);
sei();
This should yield an interrupt on pins PD2, PD3, PD4 i assume?
I have a display attached that shows the bits in PIND (which are indeed changing levels) And i have defined a uint8_t interruptTriggered = 0; at the top of the file which should get set to 1 in:
ISR(PCINT2_vect) { interruptTriggered = 1; }
I'm also showing the value of interruptTriggered
on the display but it never changes to 1.
Note: as the iotn2313.h file included by AtmelStudio 6.1 somehow doesn't include all definitions i took some liberties by defining the following:
//fix some missing definitions for Attiny2313
#define PCMSK2 _SFR_IO8(0x05)
#define PCMSK1 _SFR_IO8(0x04)
#define PCMSK0 _SFR_IO8(0x20)
#define PCINT11 0
#define PCINT12 1
#define PCINT13 2
#define PCINT14 3
#define PCINT15 4
#define PCINT16 5
#define PCINT17 6
#define PCINT1_vect _VECTOR(13)
#define PCINT2_vect _VECTOR(14)
#define PCIE0 5
#define PCIE1 3
#define PCIE2 4
PCMSK2
andPCINT11:17
(etc) in the datasheet? Can you add a link to the datasheet you are using? \$\endgroup\$