Serial Programming of the Stamp and Prop and the reset line.
Martin_H
Posts: 4,051
These are likely a somewhat basic questions, but I'm having nagging questions about how micro-controllers are serially programmed.
As near as I can tell the Basic Stamp 2 uses ground plus three pins (tx, rx, and reset) for programming. The propeller also seems to use four pins as well. Since there's no clock line I assume this is asynchronous serial communication and since the stamp is programmed via RS-232 it is asynchronous as well.
What bothers me is why is the reset line needed? From what I've observed right before the new program is downloaded a reset is sent. The stamp then starts executing the old program, stop, then downloads the new one and then runs it.
So my guess is that a stamp can only receive a program from the serial line for a short time after a reset is sent. Is this guess correct? If so then does reset play the same role for the propeller?
Things get weird for me because I've heard some ISP's only use tx and rx, while the AVR uses six pins (tx, rx, reset, sck, +5, and ground) from the same RS 232 connector. The presence of a clock line seems weird because the Stamp implies that RS-232 is asynchronous serial, yet the AVR cables imply it is synchronous.
Does RS-232 also support a clocked mode, or are these extra pins for show?
As near as I can tell the Basic Stamp 2 uses ground plus three pins (tx, rx, and reset) for programming. The propeller also seems to use four pins as well. Since there's no clock line I assume this is asynchronous serial communication and since the stamp is programmed via RS-232 it is asynchronous as well.
What bothers me is why is the reset line needed? From what I've observed right before the new program is downloaded a reset is sent. The stamp then starts executing the old program, stop, then downloads the new one and then runs it.
So my guess is that a stamp can only receive a program from the serial line for a short time after a reset is sent. Is this guess correct? If so then does reset play the same role for the propeller?
Things get weird for me because I've heard some ISP's only use tx and rx, while the AVR uses six pins (tx, rx, reset, sck, +5, and ground) from the same RS 232 connector. The presence of a clock line seems weird because the Stamp implies that RS-232 is asynchronous serial, yet the AVR cables imply it is synchronous.
Does RS-232 also support a clocked mode, or are these extra pins for show?
Comments
The Stamp's downloading protocol is documented in the PBasic Tokenizer Library documentation here: www.parallax.com/tabid/440/Default.aspx.
The Propeller's downloading protocol is documented via a "sticky" thread in the Propeller forum (Graham Stabler's Good Thread Index) under "Propeller loader" here: http://forums.parallax.com/showthread.php?p=609066
In both cases, there's a timeout. If specific handshaking isn't successful within a certain period of time, the Stamp and Propeller will start executing the program stored in EEPROM. In the case of the Propeller, if there's no EEPROM present, the Propeller will stop all cogs and hang in a low power mode.
Similarly for the Prop, it looks for a specific pattern of bits only just after it comes out of reset. The Prop at that time is running off its relatively uncalibrated RCfast clock, so it can't depend on standard RS232. Instead it uses a scheme that encodes bits kind of like the dits and dahs of Morse code, a high pulse of width 1T is a "1" and a pulse of width 2T is a "0", where T is a relative constant that is determined right after the Prop comes out of reset.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
As an aside understanding the Stamp clarified what the heck people are talking about when the say an Arduino is an AVR flashed with a boot loader. An AVR requires a six pin SPI programmer, so those extra pins are because the programmer turns the async serial into synchronous serial! The Arduino boot loaded makes an AVR only require rst, tx, and rx because the firmware downloads the program much like your stamp programmer in PBASIC!