The following information is being supplied for those people wanting to write host software for the M68HC705PGMR board. Currently the only two hosts supported by Motorola software are the I.B.M. PC and the Apple Macintosh. PLEASE NOTE THAT NEITHER MOTOROLA NOR THE AUTHOR ARE ABLE TO PROVIDE CUSTOMERS WITH ANY ASSISTANCE IN ADAPTING THE SUPPLIED SOFTWARE TO WORK WITH OTHER HOSTS. The I.B.M. PC and Macintosh versions of PROG705 both use the driver described in this document. How the M68HC705PGMR board works: When the M68HC705PGMR board is powered up, the MC68HC705C8 is placed into a special 'bootstrap' mode. In this mode, a program stored in a small amount of on chip ROM gains control of the CPU. This 'Bootstrap' ROM contains various routines to allow programming of the MC68HC705C8's on chip EPROM. The mode switches attached to Port D determine which of the various routines will be executed. For proper communication to take place with a host computer, the 'Load Program In RAM & Execute' routine must be selected by setting switch 'S1', 'S3', and 'S4' to 'off' and switch 'S2' to 'on' before power is applied to the board. For additional information, please consult the M68HC705PGMR boards operation manual. In the 'Load Program In RAM & Execute' routine, a user program may be downloaded via the SCI port to the internal RAM and then executed (in this case it will be the HC705C8 driver program). Data is loaded sequentially starting at RAM address $50. After the last byte is loaded, control is transferred to the program which must start at $51. The first byte that was loaded (at $50) is a count of the total number of bytes contained in the program plus the count byte. During initialization, the SCI is configured for NRZ data format (idle line, one start bit, eight data bits, and one stop bit). The baud rate is 4800 with a 2 MHz crystal. How the HC705C8 driver program works: Once the HC705C8 driver program is loaded, the MC68HC705C8 sits in a loop waiting for the host to send a command byte. When the HC705C8 receives a byte from the host, it checks to see if it is a valid command. If the command is not valid, an ASCII NAK ($15) is sent back to the host. The reason that I did this was to make it easy to detect whether or not the driver program had already been loaded into the HC705C8. Each time the host attempts to perform an action, it will try to download the HC705C8 driver program. The first byte (the byte count) is sent by the host to the HC705C8, if the HC705C8 sends a NAK to the host the host can then assume that the driver program is already resident in the HC705C8 RAM (because the byte count will always be greater than the highest command number allowed). If a NAK is not received within .5 seconds, the host will continue to send the HC705C8 driver program to the HC705C8. When the driver program is first loaded into the HC705C8 it will send an ASCII ACK ($06) back to the host to let it know that everything went OK. If the host does not receive the ACK within .5 seconds, it should inform the operator that a problem may exist and attempt to re-send the driver. Authors Note: The supplied version of the driver program is 168 bytes in length. With the amount of stack space that the program uses for subroutine calls, only two bytes of RAM remain unused. Also, the driver program IS NOT an example of good programming 'style' since it uses self modifying code extensively. The use of self modifying code was necessary because of the lack of a 16-bit pointer register in the 6805 architecture. Unless you are a very experienced 6805 programmer, it is recommended that you NOT try to modify the driver program. There are nine commands that are recognized by the HC705C8 driver program. They are: Command # Description 0 Program a block of data into the on chip EPROM. 1 Dump a block of EPROM data to the Host. 2 Send an ACK back to the host. 3 Load a program into RAM and execute it. 4 Turn the Program LED On. 5 Turn the Program LED Off. 6 Turn the Verify LED On. 7 Turn the Verify LED Off. 8 Blank check a block of EPROM. Program Command Format: <$00> After sending the 'Program Command' ($00), a two byte address, followed by a byte count should be sent. Each byte of data to be programmed into the EPROM is then sent to the HC705C8. After each byte is programmed, the data at the programmed location is echoed back to the host. The host should wait for this echoed byte before sending the next byte to be programmed. Note: Because of the current implementation of the MC68HC705C8, the entire EPROM array must be programmed TWICE before it can be verified. The first time the host software programs the EPROM array, the data byte echoed back to the host should be ignored. During the second programming operation, the host should check the the received byte against what it sent to the MC68HC705C8. Dump Block Command Format: <$01> After sending the 'Dump Block Command' ($01), a two byte address, followed by a byte count should be sent. The HC705C8 will then send the number of bytes specified in the byte count to the host. Alive Command Format: <$02> This command can be used to see if the HC705C8 is 'Alive and Well'. The HC705C8 will send an ASCII ACK back to the host. Load RAM Command Format: <$03> This command is used to allow the operator to load small programs into the HC705C8's RAM and have the program execute when the load is complete. Essentially what this command does is read the reset vector out of the Boot ROM and place it in a JMP instruction (see the source code listing) and then execute the JMP instruction. For some reason (I really can't tell you why since I don't have the source listing for the Boot ROM code) the host must wait for approximately .25 - .5 seconds before it begins to send the program. PLED On Command Format: <$04> Allows the host to turn the 'Programmed' LED on. PLED Off Command Format: <$05> Allows the host to turn the 'Programmed' LED off. VLED On Command Format: <$06> Allows the host to turn the 'Verified' LED on. VLED Off Command Format: <$07> Allows the host to turn the 'Verified' LED off. TestBLK Command Format: <$08> The TestBLK command is used to perform a blank check on a block of EPROM (the block is erased to all zeros). If a byte within the block is not erased (­ 0) an ASCII NAK will be sent to the host and the command will be terminated. If the entire block is erased, the command is terminated by sending an ASCII ACK to the host. ; ; ; ttl 'HC705C8 Driver' page ; ; M68HC705PGMR board Driver Program ; ; written by ; Gordon Doughman ; ; Copyright 1989 ; Motorola, Inc. ; ; PortA equ $00 PortB equ $01 PortC equ $02 PortD equ $03 PADDR equ $04 PBDDR equ $05 PCDDR equ $06 SPICR equ $0A SPISR equ $0B SPIDR equ $0C SCIBR equ $0D SCCCR1 equ $0E SCCCR2 equ $0F SCSR equ $10 SCDAT equ $11 TCR equ $12 TSR equ $13 TICHI equ $14 TICLO equ $15 TOCHI equ $16 TOCLO equ $17 TCNTHI equ $18 TCNTLO equ $19 PGMREG equ $1C LAT equ $02 PGM equ $00 ; ACK equ $06 ; ASCII ACKnoledge code NAK equ $15 ; ASCII Negative AcKnoledge code MaxCmd equ 8 ; highest command number allowed. ; ; org $50 Start equ * ; ByteCnt fcb End-Start ; size of driver program plus the byte count. ; ; rsp ; reset the stack pointer (just in case...). ldaa #$ff ; preset all portc pins high. staa PortC staa PCDDR ; set all pins as outputs. ; bsr SendACK ; send an 'ACK' to the host to let it know we're alive. Main bsr InByte ; go get a byte of data from the SCI port. cmpa #MaxCmd ; have we recieved a valid command? bls CmdOK ; yes. go execute it. bsr SendNAK ; no send a NAK back to the host. bra Main ; and continue. CmdOK tax ; put the byte in the x-reg. ldx CmdTbl,x ; get the address of the command. jsr 0,x ; go execute the command. bra Main ; go back and get the next byte. ; CmdTbl fcb PgmBlk ; program a block of data. fcb DumpBlk ; Dump a block of memory to the host. fcb Alive ; send an 'ACK' to the host to let it know we're alive. fcb LoadRAM ; load a program into RAM and Execute it. fcb PLEDOn ; turn the program LED on. fcb PLEDOff ; turn the program LED off. fcb VLEDOn ; turn the verify LED on. fcb VLEDOff ; turn the verify LED off. fcb TestBlk ; check a block to see if its erased. ; InByte brclr 5,SCSR,InByte ; loop here till we receive a byte of data. ldaa SCDAT ; get the received data. rts ; return. ; OutByte brclr 7,SCSR,OutByte ; loop here till the TDR is empty. staa SCDAT ; send the byte. rts ; return. ; GetPrms equ * bsr InByte ; get the high byte of the address. staa 0,x ; save it in the instruction bsr InByte ; get the low byte of the address. staa 1,x ; save it in the instruction bsr InByte ; get the byte count (size of the block). staa ByteCnt ; save it. rts ; return. ; PgmBlk equ * ; program a block of EPROM memory. ldx #StByte+1 ; point to the instruction to modify. bsr GetPrms ; get the 16-bit address plus the byte count. ldaa 0,x ; get the high byte of the address. staa