| Home | Products | Prices | Directory | Order | Contact | New | Books | Files | Links | Other |
| Bottom of Page |
By JPK Systems Limited
jpkyle@xtra.co.nz
1. Overview
Updated: August 24, 1998
The X-Programmer provides a simple and effective method for SPI programming of Atmel microcontrollers that support serial downloads. Table 1 below lists devices that can be programmed with the X-Programmer. So what is SPI programming and how does it work? What follows is a brief introduction to this topic allowing the reader to make a decision on whether or not it is right for their application.

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
As can be seen in figure 1 the X-Programmer is an in-line box
that has a DB-9 socket to connect to a PC serial port and a DB-9 plug to
connect to your target circuit. In some cases it may be desirable to make
an adapter cable to go from an existing SPI connector on a target board
to the X-Programmer’s DB-9 plug. It is intended that the designer incorporate
a DB-9 socket on future board designs to allow direct connection of an
X-Programmer, note that the DB-9 could also be mounted on the enclosure
so there is no need to open up the product in order to re-program the microcontroller.
Figure 2 shows a typical application of SPI programming, here an X-Programmer
is being used to download new laser graphic pictures into a laser graphics
console. Note the use of an Amiga computer to run the X-Programmer, no
special software – just a terminal program, and the laser graphics console
is switched on.

Another application is shown in figure 3, a simple LED test board for
the AT90S1200 running the Atmel LEDTEST.ASM program that is distributed
with AVR Assembler (download available from http://www.atmel.com).
Here a palmtop computer is being used to download a binary file to the
target device, this is very useful for on-site software updates as there
is no need to take a bulky laptop. Once again, host independent and just
a terminal program required. The X-Programmer is totally transparent after
programming has been completed, SPI port pins can be used for other purposes
(such as LED flashing) once released by the programmer.

Power for the X-Programmer is derived from the target board and also from the serial port of the host computer (for isolated RS-232), there is no need to plug in a power supply of any kind. There are no parts or leads to loose as everything needed for programming devices is attached to the X-Programmer itself. The following chapters describe in detail how to connect and operate the X-Programmer.
2. SPI Connections
Serial programming only requires the following SPI connections to be
made; MISO, MOSI, and SCK. Note that SS need not be connected as the device
automatically assumes slave SPI status when being programmed. A total of
6 connections must be made to the X-Programmer in order to successfully
perform SPI programming, table 2 shows how to connect the various devices
supported.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note that there are 2 reset lines from the X-Programmer, this is due to differences in the way reset is handled by 89Sxxxx devices and the newer AVR devices. Power supply lines for the X-Programmer need not be connected directly to the target device’s power pins, this is just to make it clear exactly what to supply it. Power supply requirements are very low, typically 16mA at 5V, so there is no need to make significant allowances for times when the programmer is connected. It is intended that any new board designs include a DB-9 connector to allow direct connection of an X-Programmer, although any other connector can be used if desired and an adapter lead made up to connect to the programmer.
Special Note: Do not use capacitors larger than 1uF in your reset circuit, doing so increases the time-constant to a point that the X-Programmer will not accept.
There are general purpose microcontroller boards available from
several vendors, one of them is Dontronics (http://www.dontronics.com)
who make the DT103 and DT104 boards. These boards have an 8 way SIL header
for SPI connections which can be used to connect to an X-Programmer, table
3 has details on pin connections.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Once the X-Programmer is connected to a target device the transmit LED will immediately come on as serial data is being sent to the host computer. At this stage the programmer is completely transparent to your target and can do nothing unless instructed by keystrokes from a terminal program.
Your host’s RS-232 communication port must be set to the following;
Once an X-Programmer is correctly wired to a target board it can be connected to the host computer and the main menu will be displayed in the terminal program. Note that you may have to request the menu again by pressing any key other than A to F (these are menu options) unless the target is powered up after the terminal program is run. If no response is seen on the screen then there is likely to be an error in your serial communications setup.
Power for the isolated RS-232 interface is provided by the host’s RS-232 port in a similar manner to a serial port mouse. Although hardware handshaking is not actually used it must be switched on to ensure that the RTS and DTR lines stay in the high state so power can be drawn from them, RTS is linked to CTS and DTR is linked to DSR inside the X-Programmer. In some circumstances, particularly with handheld computers, there is insufficient power for the isolated interface although it has been designed and tested with Psion palmtops. If this is the case then a break-in lead can be made up that connects to the host using Txd and Rxd only while power (+5Vdc to +9Vdc) is externally injected into the X-Programmer’s RTS and/or DSR lines. Contact JPK Systems Limited if you require details on how this is done.
Select Device:
(A)89S8252
(B)89S53
(C)90S1200
(D)90S2313
(E)90S4414
(F)90S8515
If this does not appear then press the SPACE key and it will be re-sent, you can verify your data is reaching the X-Programmer by observing the Rxd LED. Powering the target (and X-Programmer - same power supply) off then on again will also cause the menu to be re-sent, if the Txd LED does not come on then there is something wrong with the connection from the target to the programmer.
Select the device you want to program by sending the corresponding letter
(press the key) in upper case only, then the programming menu will be sent
in response as shown in figure 5.
(1)Erase
(2)Rd FLASH
(3)Wr FLASH
(4)Lock bits
(5)Rd EEPROM
(6)Wr EEPROM
By keying ‘3’ the X-Programmer expects a file to be sent to it, this is indicated on screen. Select the send file option in your terminal program which will then prompt for a protocol and filename, be sure to select X-Modem-CRC (sometimes abbreviated to just X-Modem) and also ensure you have a binary file that contains your program starting from address 0000H. The terminal program will indicate file transfer progress, as each byte is received it is programmed into the target and verified in real time. Once completed the response will be either DONE! or * FAIL * in the case that there was a verify error. Any errors in the file transfer will be detected by the CRC-16 that X-Modem-CRC transfers use. If your assembler produces Intel hex files then you will need to convert them to binary before sending them to the programmer, the binary file is exactly what is programmed into the target.
Keying ‘2’ will tell the X-Programmer to read back the target device’s entire FLASH contents by X-Modem-CRC which requires your terminal program to receive a file. X-Modem does not specify filenames automatically so when you select this it will prompt for one, and then start receiving the file. Once the file transfer is complete the X-Programmer will respond with DONE!.
Options 5 and 6 behave in exactly the same manner as 2 and 3 except operations are performed on the EEPROM instead of the FLASH, this includes the auto-verify feature. Note that the EEPROM can be written over and does not need a chip erase, unlike the FLASH memory. You can use this feature for downloading new configuration information for example without having to re-load the main program.
Keying ‘4’ automatically programs all lock bits in the currently selected device.
If you are having difficulty coming to grips with X-Modem file transfers then it is suggested that you experiment with 2 computers hooked together with a null modem cable and both running terminal programs. It should be possible to type on one computer and see it on the other one, then try sending a file. Don’t forget that the receiving end must be told to expect an X-Modem file.
At any time the menu can be repeated by keying anything other than 1 to 6, this can be useful as a quick check if everything is still connected correctly.
Because the X-Programmer is transparent as soon as an operation has been completed there is no need to disconnect it from the target unless you have completed the job. During software development this means there is no need to even switch off your target as the X-Programmer has full control over the reset line, true In Circuit Programming. Simply erase the device then program it and repeat whenever necessary. No more chip swapping!
Programming speed is set by the serial communications byte rate (11 bits at 1/2400s per bit = 4.583ms) which is 14% longer than the maximum byte programming time of 4ms specified by Atmel in their AVR device data sheets. There is no way of making it go faster as byte programming is internally timed in the target device and is independent of external crystal frequency. The X-Programmer imposes minimum frequency limits on the external crystal, 2MHz for AT90Sxxxx and 8MHz for AT89Sxxxx devices. There are no upper frequency limits apart from those dictated by the target device itself. These limitations are associated with SPI timing which must be strictly adhered to for successful programming, it is possible to halve these limits by slowing down to 1200baud and changing the X-Programmer's internal crystal from 22.1184MHz to 11.0592MHz but is not recommended. Note that the AT90S2343 device is supported only when an external clock source of 2MHz or greater is provided on pin 2, the internal oscillator frequency is around 1MHz which is too slow for the X-Programmer.
Future devices are automatically supported provided they follow the same SPI programming instruction format as the current devices (quite likely), although new devices will of course be added to the device selection menu as they become available.
Due to the 128 byte block nature of the X-Modem protocol there are sometimes minor anomalies in what is written after the actual file has been sent, for example if the program is only 100 bytes long then 28 extra bytes must be added to fill the block. Usually these are 1AH characters and do not have any effect as they will only appear after the real data has been sent, just ignore them.
Enjoy the benefits of in-circuit programming!
JPK Systems Limited
November 15, 1997
Updated: August 24, 1998
| Home | Products | Prices | Directory | Order | Contact | New | Books | Files | Links | Other |
mailto: don@dontronics.com_
Copyright © 1996-99 DonTronics
| Top of Page |