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
Answer
Apparently there is a new revision of ATtiny2313, called ATtiny2313A. This document describes the differences.
The ATtiny2313A is a functionally identical, drop-in replacement for the ATtiny2313. All devices are subject to the same qualification process and same set of production tests, but as the manufacturing process is not the same some electrical characteristics differ.
Amongst other things there are more Pin Change input pins and interrupts as you already noticed.
Ensure that you selected the correct controller type in Atmel Studio, that is including the trailing A
in 2313A
, and ensure the physical device is an A
-version too.
No comments:
Post a Comment