Shop OBEX P1 Docs P2 Docs Learn Events
Serial Programming of the Stamp and Prop and the reset line. — Parallax Forums

Serial Programming of the Stamp and Prop and the reset line.

Martin_HMartin_H Posts: 4,051
edited 2010-07-21 01:17 in General Discussion
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?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-07-20 02:17
    Both the Stamps and the Propeller use a full-duplex asynchronous serial communications channel for downloading with the return channel (to the PC) used for handshaking and error checking. The Reset line is usually wired to one of the serial handshaking lines like DTR and serves to reset the chip.

    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.
  • Martin_HMartin_H Posts: 4,051
    edited 2010-07-20 02:41
    Mike, thanks for the pointers. I shall read those documents.
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2010-07-20 04:12
    In the case of the BASIC Stamp, the unique condition that starts the programming cycle is that the host makes its TX line high to create an unusual BREAK state while it pulses its DTR line 0-1-0 to reset the Stamp. The Stamp then expects a further exchange of data and handshakes with the host before it starts accepting the data that will be burned into the eeprom. The unique combination of BREAK plus reset is what puts the Stamp in programming mode. I have an write-up about it here.

    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
  • Martin_HMartin_H Posts: 4,051
    edited 2010-07-21 01:17
    Tracy Allen, thanks for the pointer as well. By reading the links I have a much better understanding of how the Stamp program download process works. Your BS2 programmer in PBASIC is quite cool.

    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!
Sign In or Register to comment.