The goal of our project was to created an MCU programmer that read ROM data from a standard IDE hard drive. Our design conisted of two ATMEGA163 microcontrollers communicating in a master-slave relationship. The slave MCU controlled a FAT32 laptop hard drive, while the master MCU handled user input (push buttons) and output (an LCD display) as well as progamming the target MCU. We chose to restrict our target MCU to an AT90S8515 because it only requires a single instruction to program its flash while the mega163 requires two instructions. The figure below shows the relationship between all the major components of our system.

We would have liked to ideally used only one microcontroller but the interface to the hard drive required 24 i/o pins alone. The LCD requires an entire port (8 pins), 4 i/o pins are needed to program the target MCU, and a minimum of two pins are required to get user input. All of these i/o requirements exceeded the 36 pins provided on a single 8515 or mega163.

To establish communication between the two MCU's, we wired their UARTs together. On power up the slave MCU does a hard reset of the hard drive and performs a listing of the root directory. The most critical information about each file (name, file size, and first cluster) is stored in an array in memory. The slave then goes into an infinite loop and waits for a request from the master MCU.

When the master MCU powers up, it sends a request to the slave for a list of all the file names it found. The master then displays the first file on the LCD and enters a a state machine to debounce button presses from the user. The user can cycle through the files and each is respectively displayed on the LCD. When the user presses the program button, the master sends the index of the file currently selected to the slave. The slave MCU responds to this request via its UART receive complete interrupt. It then reads the file from disk and streams the contents to the master.

The format of the ROM file is that produced by the CodeVison compiler. An example of that format is shown below.


Each line gives a memory address (the first six characters) followed by the value to be programmed at that address (the last four characters). Since ROM files can be quite large they would easily exceed the SRAM in a mega163, as a result we only buffer one line at a time and program each word in memory as it is streamed into the master. The master converts the ascii hex values to integers and progams the target MCU in-system by sending commands and data serially to the targets RESET, MOSI, MISO, and SCK pins.