Electronics -- Atmel/AVR-programmingPlease note that I am now using the USB-based download cable. Content on this page is no longer maintained/developed. However, the presented solution is cheap, easy to build and still working nicely. Serial downloading circuitConcerning the "circuit", serial downloading via the SPI interface of the AVR RISC microcontroller is even easier than parallel downloading: You just need 3 wires and some additional circuicy to bring the device into a mode where it accepts commands via the SPI interface and an external clock. Serial downloading is the method of choice if the microcontroller is already built into some device, because it allows in-system programming. Hence, I assume that we have access to the 3wire SPI interface of an Atmel which is part of some larger device and receives an internal clock which is fast enough for serial downloading. (The system clock must be at least 4 times as fast as the serial clock provided by the programming software via the PC's parallel port. To be exact, the serial clock must be LOW and HIGH for at least 2 system clock cycles each.) I will not provide a "circuit sheet" here because it is so trivial: You just need the "A" channel of the Latch16Bit board. Make the following connections: (Note: Pin numbers are for the DIL packages.)
That's all. Just make sure the other external components (system clock and microcontroller RESET line) are set up properly: In order to start serial downloading you need to:
The above assumed, that the microcontroller is running inside a system with power and clock applied. Alternatively, one can use the following algorithm:
Troubleshooting:
A (possibly faster) programmer could be build using the lp port directly without the Latch16Bit board by connecting MISO directly to one of the status lines and using two data lines for MOSI and SCLK. However, I prefer to have the ability to set the port into high-Z state and to have some protective chips between my PC and my other circuits. Serial downloading softwareAtmelprg is a programmer tool which can perform both the parallel and the serial up/downloading of flash and EEPROM content.
Note:
After downloading the source code, you need to manually configure the
code before compiling it:
Also note that in serial mode, Atmelprg
may ask you to perform some actions manually, e.g. to give RESET a
positive pulse after "chip erase" command. bash# ./atmelspi -erase -readflash -readeeprom -dumpasc flash -dumpasc eeprom Waiting to enter serial programming mode (press enter)... Enabling SPI programming: OK [0x00ac5300] Detected device: (0x1e9401) Device name: ATMega161 Flash size.: 16384 bytes [0x2000 words] Vendor.....: Atmel EEPROM size: 512 bytes Has PAGEL: yes; Fuse+Lock: 2 bytes; ChipErase: RDY/BSY Performing chip erase... SPI: Chip erased. Give RESET a positive pulse. Serial programming done (left programming mode). Waiting to enter serial programming mode (press enter)... Enabling SPI programming: OK [0xac5e5300] Detected device: (0x1e9401) Device name: ATMega161 Flash size.: 16384 bytes [0x2000 words] Vendor.....: Atmel EEPROM size: 512 bytes Has PAGEL: yes; Fuse+Lock: 2 bytes; ChipErase: RDY/BSY Reading flash into buffer "flash" (16384 bytes)... done Reading EEPROM into buffer "eeprom" (512 bytes)... done Dumping buffer "flash" (16384 bytes) [skipping 0x0000..0x1fff: 8192 words 0xffff] Dumping buffer "eeprom" (512 bytes) [skipping 0x0000..0x00ff: 256 words 0xffff] Serial programming done (left programming mode).
|