Closed GoogleCodeExporter closed 9 years ago
Hi, I wil look at this. According to the schematic of Nano 3.0, pin 4 is
connected to ground. Are you sure you're using pin 4?
Original comment by m...@schwager.com
on 2 Feb 2012 at 1:50
Ok, one problem we have: The PinChangeInt code is designed to work on the
Arduino Uno / Duemilanove. The Arduino files to convert between Arduino pin
numbers and the ATmega328p ports are not the same on those as they are on the
Nano. So when you say you are working with pin 9 on the Nano, this is D6.
Thus you must define the attachInterrupt() function in PinChangeInt as working
with pin 12. Sorry about that, but I don't have a Nano :-(. Worse, the
digitalPinToPort(), digitalPinToBitMask(), etc. macros/functions that the
library uses actually come from the Arduino header files, which aren't set up
to work with the Nano. In short, for me to modify the code to work with the
Nano would be fairly difficult and without a Nano of my own I'm reluctant to
work on it. At present, it's easier (especially for me) to ask that you refer
to the Nano schematic:
http://arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf , look at the pin
you want to use in the upper left hand corner, then check to see what is the
Arduino Uno / Duemilanove equivalent pin there (D6, D7, A3 etc.), and correlate
that to the port using the diagram at
http://arduino.cc/en/Hacking/Atmega168Hardware . For example: Pin 6 on the
Nano is D3. You want to attach an interrupt to pin 3, then, like this:
PCintPort::attachInterrupt(3, &yourfunction, FALLING); This is the same as
PORTD, pin 3.
Original comment by m...@schwager.com
on 2 Feb 2012 at 5:10
Let me know if that helps.
Original comment by m...@schwager.com
on 2 Feb 2012 at 5:11
Hmmm... I've been using a nano without issue. In your example sketch where
you define the pin number, I use the digital pin number as labeled on the chip.
So, for D2, I #define Pin1 as a 2. I have only tested this for digital input
pins on the nano D2 - D7. Your explanation seems harder than this. I have the
nano selected in the Arduino IDE and I'm on Arduino 1.0.
Original comment by steve.ha...@gmail.com
on 3 Feb 2012 at 4:40
I should also note I'm still using pinchangeint v1.3.
Original comment by steve.ha...@gmail.com
on 3 Feb 2012 at 5:06
Abstract: IGNORE MY COMMENT 2
Interesting, Steve. I don't know how that works, though. If you tell the
library to attach to D2, that's pin 32 on the Arduino. ...Ooooh!!! I get it.
It's the 32 pin MLF package, which has a different pinout than the 28 pin DIP-
that's what confused me. So, it's still pin 2 on PORT D. The physical port on
the Arduino never really enters into it, it's the PORT and pin (aka, "PD2")
that count. Thanks!
Please ignore my previous rambling.
Original comment by m...@schwager.com
on 3 Feb 2012 at 4:17
If your code works on 1.3, it should work with 1.4. No structural changes were
made inside that (theoretically) would affect the selection of pins.
Original comment by m...@schwager.com
on 3 Feb 2012 at 4:19
Glad to hear it's making sense. You have a note on your Wiki under Usage
that states the nano won't work and translation is required. If this is
all good now, you might want to update that. It's working great for me!
Original comment by steve.ha...@gmail.com
on 3 Feb 2012 at 5:33
There is indeed a bug in my code. Thanks to Ron for finding it. The
attachInterrupt switch statements are missing the "break" statements. I
believe they should look like this:
switch (portNum) {
#ifndef NO_PORTB_PINCHANGES
case 2:
port=&portB;
break;
#endif
#ifndef NO_PORTC_PINCHANGES
case 3:
port=&portC;
break;
#endif
#ifndef NO_PORTD_PINCHANGES
case 4:
port=&portD;
break;
#endif
}
...I continue to investigate.
Original comment by m...@schwager.com
on 13 Feb 2012 at 6:01
I have 1.6beta available for download. Let me know if it makes things better.
I am also working on a test sketch that will hopefully uncover some of these
things in the future.
Original comment by m...@schwager.com
on 23 Feb 2012 at 6:29
Thanks. I will try this out too as I only need interrupts on Port D enabled.
Original comment by steve.ha...@gmail.com
on 23 Feb 2012 at 7:49
My test script is completed. I now test with it, and with a rotary encoder
library that I wrote. Double the testing for double the fun! I think this is
completed and will mark this as Finished in a few days.
Original comment by m...@schwager.com
on 28 Feb 2012 at 11:07
I tested the latest version 1.7 on my nano and it is successfully reading 6
receiver channels. I've enabled the NO_PORTB_PINCHANGES and
NO_PORTC_PINCHANGES flags and am using the pin state variable in my sketch.
Thanks a bunch!
Original comment by steve.ha...@gmail.com
on 29 Feb 2012 at 5:42
Killer! :-) Thanks for the update. Setting the flags should make for a
fairly nice speed bump; especially it will help make the pin state variable
accurate.
Original comment by m...@schwager.com
on 29 Feb 2012 at 3:37
This has been fixed for some time. I'll stick a fork in it and call it done.
Original comment by m...@schwager.com
on 25 Apr 2012 at 12:34
Original issue reported on code.google.com by
Kestr...@att.net
on 28 Jan 2012 at 1:53