When I insert this line in my code:
On interrupt PinChange6 Call Encoder_Interrupt
I get this error:
Error: Invalid interrupt event: PINCHANGE6
Also, the Mega328P supports pin change interrupts up to PCINT23. I only see On Interrupt definitions up to PCINT7 in the Help. How far does GCB go with these interrupts?
Joe
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, I guess I really don't understand how this works on the AVR. I'm trying to set up pin change interrupts for a rotary encoder on an Arduino Uno, pins D0 and D1. Any suggestions?
Joe
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmmm..seems that all interrupts except INT0 and INT1 are level triggered...not good for an encoder app. My Arduino LCD shield already uses the INT0 and INT1 pins (PortB.0 & PortB.1), so I guess I'm going back to the drawing board on this one.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK, got it, after a lot of fumbling! Pin change interrupts DO work on state change as advertised.
Turns out there aren't many free I/O pins left on the Uno board after you plug in an LCD shield, a serial I/O channel and an I2C device. I was using pins that already had signals on them, causing unexpected interrupts. I moved my encoder to pins D2 and D3. Here's the interrupt setup code that made it work:
PCICR.PCIE2 = 1 'Enables interrupts on pin group PCINT23..16 & maps them to PCINT2
PCMSK2.PCINT18 = 1 'Enables specific interrupt PCINT18, PORTD.2
PCMSK2.PCINT19 = 1 'Enables specific interrupt PCINT19, PORTD.3
On interrupt PinChange2 Call Encoder_Interrupt 'Calls encoder sub on interrpt
Now off to write an interrupt-driven encoder handler!
Joe
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I insert this line in my code:
On interrupt PinChange6 Call Encoder_Interrupt
I get this error:
Error: Invalid interrupt event: PINCHANGE6
Also, the Mega328P supports pin change interrupts up to PCINT23. I only see On Interrupt definitions up to PCINT7 in the Help. How far does GCB go with these interrupts?
Joe
This was my misunderstanding on how the AVR Pin Change interrupts work. I think I know what I'm doing wrong.
Sorry
Well, I guess I really don't understand how this works on the AVR. I'm trying to set up pin change interrupts for a rotary encoder on an Arduino Uno, pins D0 and D1. Any suggestions?
Joe
Hmmm..seems that all interrupts except INT0 and INT1 are level triggered...not good for an encoder app. My Arduino LCD shield already uses the INT0 and INT1 pins (PortB.0 & PortB.1), so I guess I'm going back to the drawing board on this one.
OK, got it, after a lot of fumbling! Pin change interrupts DO work on state change as advertised.
Turns out there aren't many free I/O pins left on the Uno board after you plug in an LCD shield, a serial I/O channel and an I2C device. I was using pins that already had signals on them, causing unexpected interrupts. I moved my encoder to pins D2 and D3. Here's the interrupt setup code that made it work:
Now off to write an interrupt-driven encoder handler!
Joe