Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Pin Change Interrupts don't work on the Arduino Mega

3 posters

Go down  Message [Page 1 of 1]

CommandMC

CommandMC

Hello, I'm trying to use the Arduino library EnableInterrupt to enable Pin Change Interrupts on an Arduino Mega, which does not work.
Using the same library & code on the Uno works fine. Using the builtin "attachInterrupt" function (which uses External Interrupts) also works, but that only works for a select number of pins of course.

I've used the following code to test this, hooking up a Clock to the specified pin:
Code:
#include <EnableInterrupt.h>
#define ARDUINOPIN 7

volatile int intCount = 0;

void setup() {
  Serial.begin(9600);
  enableInterrupt(ARDUINOPIN, interrupt, RISING);
}

void loop() {
  Serial.println(intCount);
  delay(50);
}

void interrupt() {
  intCount++;
}



Last edited by arcachofo on Sat May 14, 2022 5:30 pm; edited 1 time in total (Reason for editing : Mark as unsolved (red color))

arcachofo

arcachofo

Hi. Thanks for reporting.

I will have a look.

arcachofo

arcachofo

Had a fast look and looks like Mega has no interrupts for Pin 7:

Pin Change Interrupts don't work on the Arduino Mega Megpin10

Can you confirm that this is the problem?

CommandMC

CommandMC

Well that's definitely part of the problem, however even after using one of the pins that support Pin Change Ints (A8 in this case) it still doesn't seem to work. Am I doing something wrong here? Code is the same as above (just changing the pin to A8 of course)
Pin Change Interrupts don't work on the Arduino Mega 9QC6CDf

CommandMC

CommandMC

Huh, seems like only the Analog Pins don't work. Tried D10 now and that works fine.

arcachofo

arcachofo

Huh, seems like only the Analog Pins don't work. Tried D10 now and that works fine.
Might be that External Interrupts are working fine but there is some problem with Pin Change Interrupts.

This needs more in deep testing, I will have a look.

CommandMC

CommandMC

Thanks! Also, as a quick note: The builtin Code Editor does not seem to be able to compile for Mega, I've had to build using Arduino IDE and then load the hex file. Searched around a bit and it seems like I'd have to set the board in the compiler properties, which isn't possible anymore since the Properties tab got replaced/removed

arcachofo

arcachofo

it seems like I'd have to set the board in the compiler properties, which isn't possible anymore since the Properties tab got replaced/removed
Just right-click in the document and choose "Properties".

CommandMC

CommandMC

Just right-click in the document and choose "Properties".
Ah, got it. Well, thanks again!

Ed Graham



arcachofo wrote:
Huh, seems like only the Analog Pins don't work. Tried D10 now and that works fine.
Might be that External Interrupts are working fine but there is some problem with Pin Change Interrupts.

This needs more in deep testing, I will have a look.

Hi @arcachofo,

Did you get anywhere with this in the end?  I am having exactly the same problem in April 2022: the Pin Change Interrupts for analogue pins on the Arduino Mega are not being picked up by SimulIDE, whereas for the digital pins they are.

arcachofo

arcachofo

Hi Ed. which version are you using?

Ed Graham



arcachofo wrote:Hi Ed. which version are you using?

I am using SimulIDE-0.4.15-SR9.

arcachofo likes this post

arcachofo

arcachofo

Solved for 0.415 in Rev 278.

1.0.0 not solved yet.

Ed Graham likes this post

Ed Graham



arcachofo wrote:Solved for 0.415 in Rev 278.

1.0.0 not solved yet.

Fantastic! Where can I download Rev 278 from?

arcachofo

arcachofo

That is commit nº 278, jus for reference.
I will upload update soon.

Ed Graham likes this post

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum