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);

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
  • \$\begingroup\$ Where did you find reference to PCMSK2 and PCINT11:17 (etc) in the datasheet? Can you add a link to the datasheet you are using? \$\endgroup\$
    – jippie
    Jul 18, 2015 at 8:04
  • \$\begingroup\$ @jippie atmel.com/images/doc8246.pdf page 255 \$\endgroup\$
    – Mervin
    Jul 18, 2015 at 8:16

1 Answer 1


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.

  • \$\begingroup\$ I'm not sure what to change after reading that document though: \$\endgroup\$
    – Mervin
    Jul 18, 2015 at 8:20
  • \$\begingroup\$ @Mervin You have to select the correct device in AtmelStudio. BTW: There is a version 6.2, but I don't know the differences with 6.1. \$\endgroup\$
    – jippie
    Jul 18, 2015 at 8:21
  • \$\begingroup\$ @Mervin And of course ensure you actually have a physical 2313A device. \$\endgroup\$
    – jippie
    Jul 18, 2015 at 8:24
  • \$\begingroup\$ it seems the store sold me a non-A version, gotta love old stock \$\endgroup\$
    – Mervin
    Jul 18, 2015 at 8:27
  • \$\begingroup\$ I'm assuming this is the problem then, i assumed i had the A version. Since i'll be receiving and replacing it with a attiny4313 today i'll leave things as they are (since the 4313 should work the same as a 2313_A_ \$\endgroup\$
    – Mervin
    Jul 18, 2015 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.