Programming the flash memory

An MSP430s using flash ROM can program themselves using software, but there is an initial chicken-and-egg problem getting the programming software into the chip in the first instance.

Fortunately, there are two ways you can do this on a "bare" MSP430:

JTAG is a JEDEC-standard in-circuit testing interface. It uses 4 pins: mode, clock, data in and data out. It's basically a big shift register. You can chain devices together by connecting the in and out pins to make one giant whole-board shift register, and take over the I/O pins for various sorts of board testing.

There are also a few opcodes reserved to for manufacturer extensions, which TI uses for remote access and debugging purposes.

All MSP430 devices have a JTAG port, although on the 20- and 28-pin parts, the pins are multiplexed with normal I/O pins and only a dedicated "test" pin is needed, to enable the JTAG functionality.

The full capabilities of TI's extensions to the JTAG port are rather extensive, and include stopping and single-stepping the processor. See TI's app. note slaa149 for details.

But, in particular, you can perform arbitrary memory accesses, and thereby program the flash ROM.

This is quick, if you can do all the complex wiggling of the JTAG control lines fast enough, but that's rather complex piece of work.

An alternative is a bootstrap loader that is included on all flash MSP430 processors and uses standard 9600 baud asynchronous communications. For those parts with 2k of RAM you can download a replacement BSL and use 38400 baud. Downloading this at 9600 baud, and then flashing at 38400 baud is faster for programs larger than about 10k bytes.

This is also invoked by special wiggling of the TEST input while RESET is active. (For parts with a dedicated JTAG interface, and thus no TEST pin, TCK is used instead.)

All this requires is some level-shifters and a serial port. See TI application notes slaa089a and slaa096b for details.