|
1893
|
Using Arduino / Programming Questions / Re: When does -1 != -1 ?
|
on: December 22, 2011, 09:47:33 pm
|
|
Great work guys, indeed adding another variable makes the problem go away. I did notice, for the original sketch, the IDE reports Binary sketch size: 824 bytes, but avrdude only writes and verifies 822 bytes. With an added variable, the sizes then agree.
So how would the problem be summarized? The last static variable cannot be initialized to -1? Not sure whether "last" is always controllable from the source code.
|
|
|
|
|
1894
|
Using Arduino / Programming Questions / Re: When does -1 != -1 ?
|
on: December 22, 2011, 06:02:32 pm
|
Upon reading the original post of this thread I thought this was another beginner programming issue.
Understandable, I'm sure you're not alone! Well this looks like a nice challenge!
Indeed, I'd sure like to understand it at least. OTOH it would not seem to be common or it would have been found before now.
|
|
|
|
|
1896
|
Using Arduino / Microcontrollers / Re: i want to learn how to program a microcontroller...
|
on: December 22, 2011, 05:49:16 pm
|
So im sure we all know how to use a arduino. Its so easy, the arduino enviroment does everything for you! I want to learn how to use a avr or pic. For testing purposes im planning on using it to control relays which will control christmas lights. Can someone point me in the right direction(some tutorials or something) and should i start with a pic or avr? my main concern is the software because i have a mac and no access to windows. The only microcontrollers that ive used are arduino and picaxe. Thanks  Well, Arduino is built around an AVR, so you're already partway there. I got an ICSP programmer and downloaded WinAVR, that's one path you could go down. Or get AVR Studio from Atmel (no experience there, it's another one of those things I'm not getting around to). Also plan on spending considerable time reading the AVR datasheet(s). But that's half the fun!
|
|
|
|
|
1897
|
Using Arduino / Programming Questions / Re: When does -1 != -1 ?
|
on: December 22, 2011, 05:42:49 pm
|
If I change the -1 to -2, then the LED stays off The difference between the two HEX files is what would be expected (four bytes different). The difference between the two ELF files is exactly what would be expected. And, that test eliminates #1. Thanks for the input. What would be the next step? How do we validate #2?
|
|
|
|
|
1898
|
Using Arduino / Programming Questions / Re: When does -1 != -1 ?
|
on: December 22, 2011, 01:56:40 pm
|
both turn the LED on for my uno but not on my duemilanove.
Got me to thinking. Loaded the sketch with ICSP, LED stays off. Burned the ATmegaBOOT_168_atmega328.hex bootloader (Arduino Duemilanove or Nano w/ ATmega328) and loaded the sketch with the bootloader, LED stays off. Something funny with Optiboot?
|
|
|
|
|
1901
|
Using Arduino / Programming Questions / Re: When does -1 != -1 ?
|
on: December 22, 2011, 01:16:30 pm
|
Attached is avr-objdump output with Serial.begin added as follows. Edit: The code generated by the if statement appears the same, except for different addresses, which would be expected. #define TEST_VALUE -1 int foo = TEST_VALUE;
void setup(void) { Serial.begin(9600); pinMode(13, OUTPUT); if (foo != TEST_VALUE) digitalWrite(13, HIGH); }
void loop(void) { }
|
|
|
|
|
1902
|
Using Arduino / Programming Questions / Re: When does -1 != -1 ?
|
on: December 22, 2011, 01:12:52 pm
|
If I change the -1 to -2, then the LED stays off. I compared the avr-objdump output from the two and only found the following, which is about what I'd expect. Scary. Compare: (<)C:\Documents and Settings\Jack\Desktop\objdump-2.txt (18814 bytes) with: (>)C:\Documents and Settings\Jack\Desktop\objdump-1.txt (18814 bytes)
134c134 < 112: 8e 5f subi r24, 0xFE ; 254 --- > 112: 8f 5f subi r24, 0xFF ; 255
|
|
|
|
|