Download AT89S8252 In-System Programming MCU Application Note

Transcript
Appendix 4: ASPECT Script for Procomm Plus
; PROCOMM ASPECT script to read and transmit an Intel hex file.
; The script does not set up communications parameters, initialize the
; modem, dial out or establish a connection with the receiver; this is
; done manually via the PROCOMM Connection Directory.
; Each record in the hex file is terminated by a CR/LF. The receiver is
; expected to respond with an ACK after each record is validated and
; programmed into the target processor. If the receiver cannot validate
; the record, it responds with a NAK. If the receiver cannot verify the
; record data after programming the target processor, it responds with
; a CAN, which tells the transmitter to abort the upload. The transmitter
; waits 2 seconds between records for a response. If a response is not
; received in the allowed interval, or if the response is other than an
; ACK or a CAN, the record is retransmitted.
#define ACK
6
; ^F
#define NAK
21
; ^U
#define CAN
24
; ^X
#define MAXRETRIES 4
proc main
string filename, record
integer retry, rxcode
sdlgfopen "Select HEX File" "*.hex" single filename; get file name
if failure
; get file name failed
exit
endif
if filename ; validate path and file name
if fopen 0 filename read; open file for read
fgets 0 record; read record
else
errormsg "FILE OPEN FAILED"
exit
endif
else
errormsg "FILE DOES NOT EXIST"
exit
endif
set aspect rxdata on
; script processes receive data
while not feof 0
; check for EOF
termwrites record
; show record
rxflush
; purge pending receive data
transmit record raw
; send record including CR/LF
comgetc rxcode 2
; wait max 2 seconds for answer
call show_rxcode with rxcode ; show received code
retry = 0
; initialize counter
5-106
Microcontroller