Home  Products Prices Directory Order Contact New Books Files Links Other
DonTronics Home Page X-Programmer Online Manual
Bottom of Page
 
Atmel AT89Sxxxx and AT90Sxxxx SPI programmer

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.
    The Serial Peripheral Interface (SPI for short) is a full-duplex 3-wire synchronous data transfer interface that is built into some of Atmel’s microcontrollers, more detailed information can be found on specific product data sheets. What is important to us is that it has been adapted for downloading programs and data into the device without the need to physically remove it from a circuit, unlike parallel programming where the device must be plugging into the programmer and then replaced into the target circuit. This means you can solder a device directly into the PCB right from the word go, no need for sockets and no need to even power the target circuit off to program it.
     
    In order to program the target device it must be powered and have a crystal as is needed to make it work anyway, the reset line is then pulled into the active state to halt any program execution. A special command sequence is sent down to the SPI interface which enables serial programming and then reading or writing can take place via the 3-wire SPI. Once programming is complete the reset line is released and program execution starts as it would upon power up.
     
    There are several simple, very low cost, DIY SPI programmers available in the public domain and they do work adequately for some jobs. Typically the target device must be removed from circuit and then hooked up to the parallel printer port of a PC and special bit bashing software run to program it. Accurate software timing on a PC running Microsoft Windows can be difficult to achieve and there are some doubts as to whether or not all timing requirements are actually met with these programmers. Also they are host dependent, that is they can only be used on an IBM compatible PC. The X-Programmer achieves host independence by using an RS-232 serial port for communications and no special software, all that is required operate an X-Programmer is a terminal program that supports X-Modem-CRC file transfers.
     
    Optical isolation is provided by the X-Programmer so there is never any concern about destroying the serial port on that $3k laptop and both host and target connections can be hot-plugged, that is they can be connected whilst power is applied to the target. Figure 1 shows the X-Programmer unplugged from both host and target.
     
    Figure 1. X-Programmer
     
    Device Part Number
    FLASH size
    EEPROM size
    AT89S8252
    8kB
    2kB
    AT89S53
    12kB
    N/A
    AT90S1200
    1kB
    64Bytes
    AT90S2313
    2kB
    128Bytes
    AT90S2323
    2kB
    128Bytes
    AT90S2343 (with ext. clock)
    2kB
    128Bytes
    AT90S4414
    4kB
    256Bytes
    AT90S4434
    4kB
    256Bytes
    AT90S8515
    8kB
    512Bytes
    AT90S8535
    8kB
    512Bytes
    Table 1. Devices supported by the X-Programmer

     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.
     

    Figure 2. Programming laser graphics images into a console.

    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.
     

    Figure 3. LEDTEST program running on an AVR, target programmed with palmtop.

    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.
     
    DB-9 Male from X-Programmer
    AT89S8252 and AT89S53 (PDIP)
    AT90S1200 and AT90S2313 (PDIP)
    AT90S2323 and AT90S2343 (PDIP)
    AT90S4414, AT90S4434, AT90S8515, and AT90S8535 (PDIP)
    Pin 1 (MOSI)
    Pin 6 (P1.5/MOSI)
    Pin 17 (PB5/MOSI)
    Pin 5 (PB0/MOSI)
    Pin 6 (PB5/MOSI)
    Pin 2 (MISO)
    Pin 7 (P1.6/MISO)
    Pin 18 (PB6/MISO)
    Pin 6 (PB1/MISO)
    Pin 7 (PB6/MISO)
    Pin 3 (SCK)
    Pin 8 (P1.7/SCK)
    Pin 19 (PB7/SCK)
    Pin 7 (PB2/SCK)
    Pin 8 (PB7/SCK)
    Pin 4 (RST)
    Pin 9 (RST)
    N/C
    N/C
    N/C
    Pin 5 (GND)
    Pin 20 (GND)
    Pin 10 (GND)
    Pin 5 (GND)
    Pin 20 (GND)
    Pin 6 (NOT RESET)
    N/C
    Pin 1 (NOT RESET)
    Pin 1 (NOT RESET)
    Pin 9 (NOT RESET)
    Pin 7 (+5V)
    Pin 40 (VCC)
    Pin 20 (VCC)
    Pin 8 (VCC)
    Pin 40 (VCC)
     

    Table 2. X-Programmer connections to a target device

     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.
     
    DB-9 Male from X-Programmer
    DT103 with AT89S8252 or AT89S52 fitted
    DT103 or DT104 with AT90Sxxxx AVR fitted
    Pin 1 (MOSI)
    Pin 4 (D5/MOSI)
    Pin 4 (D5/MOSI)
    Pin 2 (MISO)
    Pin 5 (D6/MISO)
    Pin 5 (D6/MISO)
    Pin 3 (SCK)
    Pin 6 (D7/SCK)
    Pin 6 (D7/SCK)
    Pin 4 (RST)
    Pin 8 (RST)
    N/C
    Pin 5 (GND)
    Pin 1 (GND)
    Pin 1 (GND)
    Pin 6 (NOT RESET)
    N/C
    Pin 8 (NOT RESET)
    Pin 7 (+5V)
    Pin 2 (+5V)
    Pin 2 (+5V)

     
    Table 3. X-Programmer connections to a DT103 or DT104

     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.

3. Communications to the programmer  
4. Operating the X-Programmer  
Home  Products Prices Directory Order Contact New Books Files Links Other
 

DonTronics Home Page

mailto: don@dontronics.com_
Copyright © 1996-99 DonTronics
 
 
 
Top of Page