int e l 9.2 GENERAL PURPOSE ROUTINES OPBYTE = 4 (04H) PROGRAM A PROM USING R3:R1 AS THE SOURCE ADDRESS POINTER, R2:R0 AS THE DESTINATION (PROM) ADDRESS POINTER, AND R7:R6 AS THE BYTE COUNTER. This instruction assumes that the DATA to be programmed into a PROM is stored in external memory and that the REGISTER PAIR R3:R1 (in RB0) contains the address of this external memory. REGISTER PAIR R7:R6 contains the total number of bytes that are to be programmed. The PROM is programmed sequentially and every time a byte is programmed the REGISTER PAIR R7:R6 is decremented and the REGISTER PAIRS R3:R1 and R2:R0 are incremented. Programming continues until R7:R6 equals ZERO.
The REGISTER PAIR R2:R0 must be initialized with the desired ADDRESS of the EPROM to be programmed MINUS 1. This may sound strange, but that is the way it works. So, if you wanted to program an EPROM starting at address 9000H, with the data stored in address 0D00H and you wanted to program 500 BYTES, then the registers would be set up as follows: R2:R0 = 8FFFH, R3:R1 = 0D00H, and R7:R6 = 01F4H (500 decimal). You would then put a 4 (04H) in the ACC and CALL location 30H. NOTE: In Version 1.0, if an ERROR OCCURS DURING PROGRAMMING, MCS BASIC-52 WILL TRAP THE ERROR AND ENTER THE COMMAND MODE. The user cannot handle errors that occur during the EPROM programming operation!!!!
In Version 1.1, programming errors will only be trapped if the MCS BASIC-52 device is in the COMMAND MODE. If the MCS BASIC-52 device is in the run mode, control will be passed back to the user. The user must then examine registers R6 and R7. If R6 = R7 = 0, then the programming operation was successfully completed, if these registers do not equal zero then registers R2:R0 contain the address of the EPROM location that failed to program. This feature in Version 1.1 permits the user to program EPROMS in embedded applications and manage errors, should they occur in the programming process, without trapping to the command mode.
In addition to setting up the pointers previously described, the user must also initialize the INTERNAL MEMORY locations that control the width of the programming pulse. This gives the user complete control over this critical prom programming parameter. The internal memory locations that must be initialized with this information are 64 (40H) and 65 (41H). These locations are treated as a 16 bit register pair with location 64 (40H) designated as the most significant byte and location 65 (41H) as the least significant byte. Locations 64 (40H) and 65 (41H) are loaded into TH1 (TIMER1 high byte) and TL1 (TIMER1 low byte) respectively.
The width of the programming pulse, in microseconds is determined by the following equation: WIDTH = (65536-256*DBY(64)+DBY(65))*12/XTAL microseconds conversely; DBY(64):DBY(65) = 65536-WIDTH*XTAL/12 The proper values for the "normal" 50 millisecond programming algorithm and the 1 millisecond "INTELligent" algorithm are calculated and stored by MCS BASIC-52 in external memory locations 296:297 ( 128H: 129H) and 298:299 ( 12AH: 12BH) respectively.
If the user wants to use the pre- calculated values the statements DBY(64) = XBY(296) and DBY(65) = XBY(297) may be used to initialize the prom programming width for the normal algorithm and the statements DBY(64) = XBY(298) and DBY(65) = XBY(299) can be used to initialize for the INTELligent algorithm. - 109 -