I read through "direct DDR access", and was warned that i shouldn't set the LSB to output, cause my Rx for serial won't accept any new sketches...me ending up in burning a new bootloader.
My simple question is:
Does the Pinmode-funktion intercept this? I didn't find an interception in the coresponding .c -file containing the function.
But still are wondering, why nobody has complained about his "frozen" Arduino in the forum.
And i don't wanna try out, and build a programmer
Just curious, have you tried restarting the board right as you're uploading? Hopefully, the board will connect before the pin is set to an OUTPUT. (Duemilanove has auto-reset, but worth a try in case it's too slow/fast)
But I'm guessing if that doesn't work, you will probably have to burn a new boot loader. (you can use another Arduino, or just buy a programmer for $20 :P)
PS, I have no idea if setting pin0 to OUTPUT effects whatever you were talking about!
As far as i understand how Arduino works you wont be able to break the Arduino that way. The (original, dont know about, e.g., LadyAda's) bootloader takes about 7 seconds from connecting to running.
I suppose you could try the 'old' pre-autoreset upload process. start the upload process and hit very shortly afterwards the reset button, or if you are even better in timing things you could connect/upload it..
if really everything else fails you can always get a pre-programmed 328/168 for a fracture of the cost of a programmer... and turn it itself into a programmer ,0)
edit
Gna, stupid 500 errors on this board. I just saw that CaptainObvious was faster ;0)
About your question - setting pin0 to Output simply makes the Receiving line deef ,0)
As far as I have come to understand the normal uploading of a new sketch, via the Arduino IDE and bootloader, should 'overide' any previous I/O pin mode assignment in any prior uploaded sketch, so I don't see any risk in using pin 0 as an output pin if you really need to.
A reset puts all I/O pins into tri-state input mode and then the bootloader will program the pin modes required to begin the uploading of a new sketch, including proper setting up pins 0 & 1 and setting up the serial hardware.
ok. thx a lot. you took my fear. I did't break my Arduino.
i just read this in the foundationscorner of arduino.cc, before i came to the idea of setting the pinmode in that way
It is a lot easier to cause unintentional malfunctions with direct port access. Notice how the line DDRD = B11111110; above mentions that it must leave pin 0 as an input pin. Pin 0 is the receive line (RX) on the serial port. It would be very easy to accidentally cause your serial port to stop working by changing pin 0 into an output pin! Now that would be very confusing when you suddenly are unable to receive serial data, wouldn't it?
So, i thought, writing this, would affect the regsters of arduino....and that this effect would continue after a reset. (cause it isn't mentioned in the digitalwrite-reference)
I like the idea (if i screw the bootloader or whatever) to make my new atmega into a programmer, to rescue the old one.
It did't came to me... But i had to smile.