Transfer of data between the PC and the microcontroller: Buffer1 shiftReg1 --------- shiftReg2 Buffer2 Write to board: parallel write parallel read to Buffer1 bits shifted out from Buffer2 one at a time ===================== From the Perspective of the PC: assembler: translates source --> S19 records, userProg.s19 Let's suppose our program is hexmon.s19. XDL downloader: sends a 256 byte program, P1, to the mini-board then sends hexmon.s19 (in ascii) XDL serial communication: I/O to the mini-board, e.g., W123455 (in ascii) ===================== From the Perspective of the Mini-board: Mini-board is in download mode, and reset is pressed: PC is loaded with the contents of a memory location in ROM, $BFFE $BFFE contains the address of a program in ROM that 1. reads exactly 256 bytes from the serial port, and stores them in RAM, starting at $0000; the 256 bytes are the program named P1 above. 2. when that is done, loads the PC with $0000 What does P1 do? It reads S-records, char by char (by reading from Buffer2 above), translating each character from ASCII into Hex. In our example, it is reading hexmon.s19, which is being transferred over the seriel port. P1 burns the values into EEPROM at the appropriate places Recall S-records: S1 count address data checksum Example: S10500000F08E3 0F --> 00; 08 --> 01. **But see caution below!** S111F8009600D6013DCE000202DF027EF80B18 ldaa 0, ldab 1, mul, ldx #2, idiv, ... S105FFFEF80005 org reset; fdb start S9030000FC Following is pseudo code for P1: Read type; while type == S1 { read count; read address; curaddress = address; for (i = 0; i < count-1; i++) { read the next 2 characters from Buffer2; translate them from ASCII into a 1-byte HEX value; burn the HEX value into address curaddress; curaddress++; } read and check checksum; read type; } ===================== Since P1 is stored in RAM, don't use fdb, fcb instructions in RAM! They would overwrite P1, corrupting the loading process. ===================== Now, put the board in run mode, and press reset. PC will be loaded with the contents of $FFFE, which contains the starting address of the downloaded user program (here, Hexmon) Suppose that the PC is now in serial communication mode, and it sends the command W123455 over the seriel port. Hexmon reads the characters one-by-one from Buffer2, translates the numbers into Hex, and performs the write operation (to RAM).