Loading...
  Show Posts
Pages: 1 ... 125 126 [127] 128 129 ... 171
1891  Using Arduino / Programming Questions / Re: When does -1 != -1 ? on: December 22, 2011, 10:26:25 pm
Jack,
Does westwf's optiload do the same thing?

Unknown, have not tried optiload.
1892  Using Arduino / Programming Questions / Re: When does -1 != -1 ? on: December 22, 2011, 10:11:10 pm
What I don't get (but I think I might now) is why this is a problem. Consider that you erase pages, not bytes.
...

So should only occur for partial pages (presumably the last page)?
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!

Quote
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.
1895  Using Arduino / Programming Questions / Re: When does -1 != -1 ? on: December 22, 2011, 06:00:31 pm
Yeah, just did that a bit earlier, i.e. verify with avrdude after uploading via the IDE. To my surprise, it passed verification.
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 smiley-red

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
Quote
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?
1899  Using Arduino / Programming Questions / Re: When does -1 != -1 ? on: December 22, 2011, 01:52:15 pm
Do you own a diode.  smiley-wink

LOL, yes, several hundred I believe. Didn't make any difference. Posted that earlier, look up a few posts...  smiley-lol
1900  Using Arduino / Programming Questions / Re: When does -1 != -1 ? on: December 22, 2011, 01:35:50 pm
So the if translates to exactly the same instructions after adding the Serial.begin(), but the results differ. Weird.

Yeah, that's the way I read it too. I'm running out of ideas.
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.

Code:
#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.

Code:
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
1903  Using Arduino / Programming Questions / Re: When does -1 != -1 ? on: December 22, 2011, 01:00:47 pm
Easy enough to test the diode thing. Tried a 1N4148 on both the real Uno and on the breadboarded ATmega328P. No difference with either.
1904  Using Arduino / Programming Questions / Re: When does -1 != -1 ? on: December 22, 2011, 12:46:18 pm
Attached output from: avr-objdump -d -S foobar.cpp.elf >objdump.txt

If those are not the correct options, please advise.
1905  Using Arduino / Programming Questions / Re: When does -1 != -1 ? on: December 22, 2011, 12:42:42 pm
If I run the code as is, the led is on. If I add a Serial.begin(), it stays off. Not helpful!

Indeed. Same behavior here.
Pages: 1 ... 125 126 [127] 128 129 ... 171