Globe
June 15, 2012, 9:42am
1
Yesterday I realized I was getting trouble using digital ports related code, eg: leds not flashing, interruptions not being active...
I wrote this small piece of code to find out what happened:
#define PH3 6
#define PH4 7
#define TEST 156
void setup()
{
Serial.begin(9600);
Serial.print("PH3: ");
Serial.println(PH3,DEC);
Serial.print("PH4: ");
Serial.println(PH4,DEC);
Serial.print("TEST: ");
Serial.println(TEST,DEC);
}
void loop()
{
}
which leads to this output:
PH3: 3
PH4: 4
TEST: 156
As you see, my #define lines with port names (PH3 and PH4) have wrong values, meaning they are also defined somewhere! However, if I write de the #define lines inside setup() function, it works properly...
My greatest worry is that it started to happen from a moment to another... I am using an ATMEGA 2560 MCU and didn't change any core library...
Can you help me?
Many thanks in advance.
system
June 15, 2012, 9:56am
2
Nope, no problem here with IDE 1.0 and Duemilanove (hint).
Globe
June 15, 2012, 9:59am
3
Thank you...
I tried also with Arduino 1.0 (I have 1.0 and 0023 installed) but the problem maintains. Maybe the two versions are sharing libraries...
system
June 15, 2012, 10:00am
4
A larger board, with a PORTH, perhaps?
Globe
June 15, 2012, 10:03am
5
I have a custom board. PH3 and PH4 were only an example. I have problems with any #define with a port name...
system
June 15, 2012, 10:20am
6
They are already defined.
#if defined(PH0)
# define PORTH0 PH0
#endif
#if defined(PH1)
# define PORTH1 PH1
#endif
#if defined(PH2)
# define PORTH2 PH2
#endif
#if defined(PH3)
# define PORTH3 PH3
#endif
#if defined(PH4)
# define PORTH4 PH4
#endif
#if defined(PH5)
# define PORTH5 PH5
#endif
#if defined(PH6)
# define PORTH6 PH6
#endif
#if defined(PH7)
# define PORTH7 PH7
#endif
Use something else instead of PH* unless you want to use the real port numbers.
Globe
June 15, 2012, 10:28am
7
Thank you!
Which file is that? Maybe the compiler changed the order of libraries compilation or something... I hadn't this problem two days ago...
system
June 15, 2012, 10:32am
8
hardware/tools/avr/lib/avr/include/avr/portpins.h: