Pages: [1]   Go Down
Author Topic: [FIXED][Interrupts] Is this a bug? (patch available)  (Read 1229 times)
0 Members and 1 Guest are viewing this topic.
Bologna, Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi! smiley
I spent a couple of hours trying to make a sketch work with my new Arduino Due, then I discovered a strange thing: some interrupts are never triggered...

It's clearly stated that the Arduino Due is able to attach an interrupt on any available pin (source: http://arduino.cc/en/Reference/AttachInterrupt) but it seems that interrupts on the following pins are not working: 11, 12, 14, 15, 20, 21, 25, 26, 27, 28, 29, 30, 32, A7. (I can read values correctly from each of them, but no interrupt callback is ever called)

Can anyone confirm this?

I wrote a simple sketch that attaches an interrupt to any pin from 2 to 53 and from A0 to A11:
Code:
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}

uint8_t pins[64] = {
// TX0 and RX0 can't be checked this way...
// 0,
// 1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
A0,
A1,
A2,
A3,
A4,
A5,
A6,
A7,
A8,
A9,
A10,
A11
};

for (uint8_t i = 0; i < 64; i++) {
pinMode(pins[i], INPUT);
attachInterrupt(pins[i], callback, CHANGE);
}

Serial.println("READY!");
}

void loop() {
// Nothing...
}

void callback() {
Serial.println("IT WORKS!");
}

Trigger the interrupts manually and see what happens...

Note: I know that using complex callbacks is a bad idea, but I had the same result with lighter callbacks...
Note2: If you are wondering... no, it does not work even if you attach one single interrupt to any of the pins listed above... and the affected pins are always the same. (at least till now)
« Last Edit: February 02, 2013, 11:49:31 am by Liarco » Logged

Venezuela
Offline Offline
God Member
*****
Karma: 16
Posts: 515
Ground, ground, always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Liarco.
Which Arduino IDE version you are running?
Logged

Bologna, Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for your reply! ^^

Arduino IDE: 1.5.1
OS: Mac OSX 10.7.5

I also noticed that my "L" led (pin 13) is always ON (even if I load an empty sketch)... I hope I haven't ruined my board! smiley-sad
Logged

Forum Administrator
Milano, Italy
Offline Offline
Sr. Member
*****
Karma: 23
Posts: 292
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Liarco,

thank you very much for the detailed and precise bug report.

the pins you're listing here seem to have in common one thing: they all belongs to PORTD (well, except 2).
Looking back at the interrupt implementation aehm portd is not considered at all...  smiley-red

Adding support for missing pins should be simple, I'll try to do it now.
Logged

C.

Forum Administrator
Milano, Italy
Offline Offline
Sr. Member
*****
Karma: 23
Posts: 292
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok done, I did quick test and the interrupt seems to work now.

the patch is here:
https://github.com/arduino/Arduino/commit/5edc110f61e27529116ab7ea2e732b445457985b

If you want to check it out, grab the file WInterrupts.c from here:
https://github.com/arduino/Arduino/blob/5edc110f61e27529116ab7ea2e732b445457985b/hardware/arduino/sam/cores/arduino/WInterrupts.c

and replace the one in hardware/arduino/sam/cores/arduino/WInterrupts.c.

Also the pins 20, 21 and A7 that doesn't belong to PORTD are working for me.

Logged

C.

Bologna, Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm going to try this patch as soon as I can, thank you very much for your quick support! smiley
Logged

Bologna, Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It works like a charm! smiley-grin

Thank you very much.

Main post title updated.
Logged

Pages: [1]   Go Up
Jump to: