# include constant definition if not defined ifnotdef (PP) include/ prmdef.rat endifdef # # # Please refer to the 'SYSTEM 19 UNIVERSAL PROGRAMMER 990-1902 # INSTRUCTION MANUAL'. # # pages | topic # ----------------------|---------------------------------------- # APPENDIX 2-1 to 2-4 | data translation formats # APPENDIX 3-1 to 3-8 | remote control operation and command summary # 3-8 to 3-9 | detailed error description ############################################################################## # subroutine prmini # ############################################################################### # Prom programmer power-up initialization routine. This routine also #determines if the PP was previously set-up in the computer mode, and if it #was, then the user does not have to enter commands to the PP to enable #computer control ############################################################################### byte bite, pplin, setpcr # integer ppin # # repeat { # call ppmini # initialization communications interface # call ppx(ESCAPE,1) # if PP in computer mode, send ESCAPE # and wait for a response if any for (I=1; I<=10000; I=I+1) { # wait for a response # exit loop after time out, or byte was read ists=ppin(bite) # get byte from input buffer, if any if (ists~=NODATA) # if byte returned, or error occured break # exit loop } # if (bite~=READY) { # if PP not in computer mode # must have operator enter command call putl(' ',5) # output a blank line call putl(' * enter prom programmer command ',5) call putl(' KEYBD SELECT F 1 START',5) call putl('$ (return when done): ',5) read (5,100) # 100 format(a10) # # for (I=1;I<=10000;I=I+1) { # wait fixed time for response from PP # exit loop if time out, or byte was read ists=ppin(bite) # get byte from input buffer, if any if (ists~=NODATA) # if byte returned, or error occured break # exit loop } # } # # if (ists==RCVERR) { # data receive error call bell # call putl(' ** data receive error, try again',5) next # } # if (ists==NODATA) { # call bell # call putl(' ** time out error, try again',5) call putl(' is serial line unit cable connected?',5) next # } # if (bite~=READY) { # call bell # write(5,30) # 30 format(' ** initialization error, try again') next # } # # waste some time for (I=1; I<=32000; I=I+1) { } # wait for CR and LF to be sent # at 9600 baud takes apx 2ms # repeat { # clear any CR or LF that is sent ists=ppin(bite) # get next byte if (ists==SUCCES&(bite==CR|bite==LF)) # ignore CR and LF next # else # break # } # if (ists==RCVERR) { # if got error in loop above call bell # write(5,30) # generate error message } # # if (setpcr()) # set prom programmercharacteristics break # } # return # end # # byte function pready() # ################################################################################ # After certain commands, the expected response will be a READY ('>') #character and a CR and a LF. This routine reads the next line of input data #and returns true if the characters read were as listed, else it returns false. ################################################################################ byte bite, pplin # include/ prmcom.rat # # if (~pplin(linbuf,LINMAX,linlen)|linlen~=1|linbuf(1)~=READY) # initialization error return(.false.) # else # return(.true.) # end # # byte function setpcr() # ################################################################################ # This function sends commands to the prom programmer and sets the #communication protocol and determines the PP characteristics. This #function must be included as part of initialization. If there #are no errors, the function returns true, else it returns false. ################################################################################ byte bite, pplin, pready # integer equal # include/ prmcom.rat # # len=length(SETNULLS) # makes argument random length call ppxlin(SETNULLS,len) # set nulls command # causes each record sent by PP to be terminated # by a CR and a LF if (~pready()) { # initialization error call bell # write (5,40) # 40 format(' ** bad handshake from PP, reinitialize') return(.false.) # } # # len=length(XFORMAT) # makes argument random length call ppxlin(XFORMAT,len) # data translation format if (~pready()) { # initialization error call bell # write (5,40) # return(.false.) # } # # call ppxlin('=',1) # disable time outs if (~pready()) { # initialization error call bell # write (5,40) # return(.false.) # } # # call ppxlin('G',1) # prompt for software configuration number len=length(SOFTNUM) # length of value returned by PP if (~pplin(linbuf,LINMAX,linlen)|linlen~=len|~equal(linbuf,SOFTNUM)) { call bell # call putl(' ** invalid software configuration, reinitialize',5) return(.false.) # } # return(.true.) # end # # subroutine bell # ################################################################################ # Writes a bell to the terminal ################################################################################ write(5,100) 7,7 # 100 format(2a1) # return # end # # byte function sppin(bite) # ################################################################################ # This function performs a synchronous read from the PP. It waits until #either a character has been received, or an error has occured. If an error #occured, the function returns false, else it returns true, and the character #will be returned in the byte variable BITE. ################################################################################ integer ppin # byte bite # # repeat { # wait for character ists=ppin(bite) # if (ists==RCVERR) # byte read error return(.false.) # } until(ists==SUCCES) # return(.true.) # end # # byte function pplin(line,maxlin,linlen) # ################################################################################ # PPLIN is a function used to input a single record of data from the #prom programmer. This routine operates synchronously, i.e. it will only #return to the calling routine when a line of data has been received. #The function will return true if no error occured, else it will return #false and the line length will be zero. # The vector to receive the input line is stored in the byte #vector LINE which is at most MAXLIN characters. MAXLIN must be specified #by the calling routine. # When the function returns a line of data, the line will be terminated #with a null byte, and the carriage return, line feed will be removed. The #integer parameter LINLEN will return the actual number of bytes contained #in the input vector LINE, not counting the null byte. # NOTE: because the null byte requires one byte, the maximum number #of bytes that will be stored in LINE is MAXLIN-1. # If the input vector is too small, an error will be generated and #LINE will be filled with as many bytes as will fit. On the next call #to the subroutine, the remainder of the input record (or as much as #will fit in LINE) will be returned, until the entire record has been read in. # If a serious data receive error is detected, (circular buffer overflow, #or a UART error) the function will return false, and the LINE will be #returned with LINLEN=0 and LINE(1)=EOS. # Also, this routine is written to interface with ASCII character #transmission only, (NOT BINARY DATA FORMATS, however, many other routines #including the driver will work with either binary or formatted ascii #character formats). Therefore since null bytes are meaningless, they are #filtered out by this routine. Also, if a totally blank line is recieved, #it is ignored, (e.g. a line consisting only of null bytes). ################################################################################ byte sppin,bite,line(maxlin) # integer linlen,maxlin # # linlen=0 # points to location in output buffer while (sppin(bite)) { # data input error if (bite==EOS) # if this is a null byte, ignore it next # else if (bite==LF&linlen>0) # line terminator for a non-null line return(.true.) # else if (bite==LF&linlen==0) # line terminator for a null line next # go back and get a non-empty line else if (bite==CR) # line terminator line(linlen+1)=EOS # terminate line else if (linlen==maxlin-1) { # insufficient room in input buffer line(linlen+1)=EOS # terminate line return(.false.) # indicate input buffer too small } # else { # linlen=linlen+1 # increment byte count line(linlen)=bite # } # } # # 10 linlen=0 # line(1)=EOS # return(.false.) # end # # subroutine ppxlin(line,linlen) # ################################################################################ # This subroutine accepts a random length string of bytes LINE that #is LINLEN bytes long. LINLEN must be an integer. The routine transmits the #LINE to the prom programmer and terminates the line with a CR. ################################################################################ byte line(ARB) # # call ppx(line,linlen) # call ppx(CR,1) # send line terminator return # end # # subroutine prmstp # ################################################################################ # This routine sends a command to the prom programmer to exit the computer #remote control mode allowing commands to be entered from the programmer #keyboard. This routine also disconnects the ISR vectors associated with #the device. ################################################################################ call ppxlin('Z',1) # transmit code to exit PP remote control call ppstp # disconnect vectors return # end #