Electronics
Btrieve
Motorcycling
Software

CHAPTER 3

Description of EPROM File Commands

One of the unique and powerful features of MCS BASIC-52 is that it has the ability to execute and SAVE programs in an EPROM. MCS BASIC-52 actually generates all of the timing signals needed to program most EPROM devices. Saving programs in EPROMS is a much more attractive and RELIABLE alternative relative to cassette tape, especially in control and/or noisy environments.

The hardware needed to permit MCS BASIC-52 to program an EPROM device is minimal, typically only one NAND gate, three or four transistors, and a few resistors are all that is required. Details of the hardware requirements are in the EPROM PROGRAMMlNG section of this manual.

MCS BASIC-52 can save more than one program in an EPROM. In fact, it can save as many programs as the size of the EPROM memory permits. The programs are stored sequentially in the EPROM and any program can be retrieved and executed. This sequential storing of programs is referred to as the EPROM FILE. The following commands permit the user to generate and manipulate the EPROM FILE.

3.1 DESCRIPTION OF EPROM FILE COMMANDS

COMMANDS: RAM(cr) and ROM [integer] (cr)

ACTION TAKEN:

These two commands tell the MCS BASIC-52 interpreter whether to select the current program (the current program is the one that will be displayed during a LIST command and executed when RUN is typed) out of RAM or EPROM. The RAM address is assumed to be 512 (200H) and the EPROM address begins at 32784 (8010H).

RAM

When RAM(cr) is entered MCS BASIC-52 selects the current program from RAM MEMORY. This is usually considered the "normal" mode of operation and is the mode that most users interact with the command interpreter.

ROM

When ROM [integer] (cr) is entered MCS BASIC-52 selects the current program out of EPROM memory. If no integer is typed after the ROM command (i.e. ROM (cr)) MCS BASIC-52 defaults to ROM 1. Since the programs are stored sequentially in EPROM the integer following the ROM command selects which program the user wants to run or list. If you attempt to select a program that does not exist (i.e. you type in ROM 8 and only 6 programs are stored in the EPROM) the message ERROR: PROM MODE will be displayed.

MCS BASIC-52 does not transfer the program from EPROM to RAM when the ROM mode is selected. So, you cannot EDIT a program in the ROM mode. If you attempt to edit a program in the ROM mode, by typing in a line number, the message ERROR: PROM MODE will be displayed. The following command to be described, XFER, permits one to transfer a program from EPROM to RAM for editing purposes.

Since the ROM command does NOT transfer a program to RAM, it is possible to have different programs in ROM and RAM simultaneously. The user can "flip" back and forth between the two modes at any time. Another added benefit of NOT transferring a program to RAM is that all of the RAM memory can be used for variable storage if the PROGRAM is stored in EPROM. The SYSTEM CONTROL VALUES --MTOP and FREE always refer to RAM not EPROM.

VARIATIONS:

None.

3.2 DESCRIPTION OF EPROM FILE COMMANDS

COMMAND: XFER(cr)

ACTION TAKEN:

The XFER (transfer) command transfers the current selected program in EPROM to RAM and then selects the RAM mode. If XFER is typed while MCS BASIC-52 is in the RAM mode, the program stored in RAM is transferred back into RAM and the RAM mode is selected. The net result is that nothing happens except that a few milli-seconds of CPU time is used to do a wasted move. After the XFER command is executed, the user may edit the program in the same manner any RAM program may be edited.

VARIATIONS:

None.

3.3 DESCRIPTION OF EPROM FILE COMMANDS

COMMAND: PROG(cr)

ACTION TAKEN:

The PROG COMMAND programs the resident EPROM with the current selected program. The current selected program may reside in either RAM or EPROM. This command assumes that the hardware is configured in the manner described in the EPROM PROGRAMMING section of this manual.

After PROG (cr) is typed, MCS BASIC-52 displays the number in the EPROM FILE the program will occupy.

EXAMPLE:

>LIST
  10        FOR I=1 TO 10
  20        PRINT I
  30        NEXT I

READY
>PROG
 12

READY
>ROM 12

READY
>LIST
   10        FOR I=1 TO 10
   ZO        PRINT I
   30        NEXT I

READY
>

In this example, the program just placed in the EPROM is the 12th program stored.

VARIATIONS:

None.

3.4 DESCRIPTION OF EPROM FILE COMMANDS

COMMANDS: PROG1(cr) and PROG2(cr)

ACTION TAKEN:

PROG1

Normally, after power is applied to the MCS BASIC-52 device, the user MUST type a "space" character to initialize the 8052AH's serial port. As a convenience, MCS BASIC-52 contains a PROG1 COMMAND. What this command does is program the resident EPROM with the BAUD RATE information. So, the next time the MCS BASIC-52 device is "powered up," i.e. RESET, the chip will read this information and initialize the serial port with the stored baud rate. The "sign-on" message will be sent to the console immediately after the MCS BASIC-52 device completes its reset sequence. The "space" character no longer needs to be typed. Of course, if the BAUD rate on the console device is changed a new EPROM must be programmed to make MCS BASIC-52 compatible with the new console.

PROG2

The PROG2 command does everything the PROG1 command does, but instead of "signing-on" and entering the COMMAND MODE, the MCS BASIC-52 device immediately begins executing the first program stored in the resident EPROM.

THIS IS AN IMPORTANT FEATURE!!

By using the PROG2 command it is possible to RUN a program from a RESET condition and NEVER connect the MCS BASIC-52 chip to a console. In essence, saving PROG2 information is equivalent to typing a ROM 1, RUN command sequence. This is ideal for control applications, where it is not always possible to have a terminal present. In addition. this feature permits the user to write a special initialization sequence in BASIC or ASSEMBLY LANGUAGE and generate a custom "sign-on" message for specific applications.

3.5 DESCRIPTION OF EPROM FILE COMMANDS

COMMANDS: FPROG(cr), FPROG1(cr), AND FPROG2(cr)

ACTION TAKEN:

FPROG(cr), FPROG1(cr), and FPROG2(cr) do exactly the same thing as PROG(cr), PROG1(cr), and PROG2(cr) respectively, except that the algorithm used to perform the programming function is the INTEL "INTELLIGENT" fast programming algorithm. The user MUST provide a way to increase VCC to the EPROM to 6 volts.

COMMANDS: PROG3(cr). PROG4(cr), FPROG3(cr), FPROG4(cr) (VERSION 1.1 ONLY)

ACTION TAKEN:

PROG3

The PROG3 COMMAND functions the same way as the PROG1 COMMAND previously described, except that PROG3 also saves the system control value, MTOP, when it is evoked. During a RESET or power- up sequence MCS BASIC-52 will only clear the external data memory up to the MTOP value that was saved when the PROG3 COMMAND was evoked. This permits the user to "protect" regions of memory from being cleared during a RESET or power-up condition. In typical use, the PROG3 COMMAND assumes that the user is saving some critical information in some type of battery-backed-up or non-volatile memory and does not want this information to be destroyed during a RESET or power-up sequence.

PROG4

The PROG4 COMMAND is a combination of the PROG2 and PROG3 COMMAND. PROG4 saves the same information as PROG3, but also executes the first program stored in the EPROM after a RESET or power-up condition.

FPROG3 and FPROG4

The FPROG3 and FPROG4 commands save the same information as the PROG3 and PROG4 commands respectively, except that the INTELIigent(tm) algorithm is used to program the EPROM.

VARIATIONS:

None.

COMMANDS: PROG5(cr), PROG6(cr), FPROG5(cr), FPROG6(cr) (VERSION 1.1 ONLY)

ACTlON TAKEN:

PROG5 & FPROG5

The PROG5 command saves both the baud rate information and the MTOP information, just like the PROG3 command previously described. However, during a RESET or power-up condition the MCS BASIC-52 device examines external data memory location 5FH (95 decimal). If the user has placed the value 0A5H (165 decimal) in this location, the MCS BASIC-52 device will not clear the external memory during a RESET or power-up condition. This permits the user to "save" programs in external memory, providing some type of battery back-up scheme has been employed.

Normally, when using the PROG5 command to establish the RESET or power-up condition, the MCS BASIC-52 device will enter the command mode after RESET or power-up. However, if the user wishes to execute the program stored in external memory, the character 34H (52 decimal) needs to be placed in external memory location 5EH (94 decimal). Placing a 34H in location 5EH causes MCS BASIC-52 to enter the "RUN TRAP MODE." Details of this mode are presented in chapter 8 of this manual.

PROG6 & FPROG6

Does the same thing as PROG5, but CALLS external program memory location 4039H during a RESET or power-up sequence. This option also requires the user to put the character 0A5H in external memory location 5FH to insure that external RAM will not be cleared during RESET or power-up. The user must put an assembly language initialization routine in external code memory location 4039H or else this RESET mode will crash. When the user returns from the customized assembly language RESET routine, three options exist:

OPTION 1 FOR PROG6

If the CARRY BIT is CLEARED (CARRY = 0) upon return from the user RESET routine MCS BASIC-52 will enter the auto-baud rate determining routine. The user must then type a space character (20H) on the terminal to complete the RESET routine and produce a RESET message on the terminal.

OPTION 2 FOR PROG6

If the CARRY BIT is SET (CARRY = 1) and BIT 0 of the ACCUMULATOR is CLEARED (ACC. 0 = 0) MCS BASIC-52 will produce the standard sign-on message upon return from the user supplied RESET routine. The baud rate will be the one that was saved when the PROG6 option was used.

OPTION 3 FOR PROG6

If the CARRY BIT is SET (CARRY = 1) and BIT 0 of the ACCUMULATOR is SET (ACC. 0 = 1), MCS BASIC-52 will execute the first program stored by the user in EPROM (starting address of the program is 8010H) upon return from the user supplied RESET routine.

 

Copyright © Madis Kaal 2000-