intel MCS BASIC-52 — Intel MCS BASIC-52 Versions 1 & 1.1 Operating and Reference Manual PDF (EN)

int e l 4.5 DESCRIPTION OF STATEMENTS STATEMENTS: CLOCK1 and CLOCK0 MODE: COMMAND AND/OR RUN TYPE: CONTROL CLOCK1 The CLOCK1 STATEMENT enables the REAL TIME CLOCK feature resident on the MCS BASIC- 52 device. The special function operator TIME is incremented once every 5 milliseconds after the CLOCK1 STATEMENT has been executed. The CLOCK1 STATEMENT uses TIMER/COUNTER 0 in the 13-bit mode to generate an interrupt once every 5 milliseconds. Because of this, the special function operator TIME has a resolution of 5 milliseconds. MCS BASIC-52 automatically calculates the proper reload value for TIMER/COUNTER 0 after the crystal value has been assigned (i.e. XTAL=value).

If no crystal value is assigned, MCS BASIC-52 assumes a value of 11.0592 MHz. The special function operator TIME counts from 0 to 65535.995 seconds. After reaching a count of 65535.995 seconds TIME overflows back to a count of zero. Because the CLOCK1 STATEMENT uses the interrupts associated with TIMER/COUNTER 0 (the CLOCK1 statement sets bits 7 and 2 in the 8052AH's special function register, IE) the user may not use this interrupt in an assembly language routine if the CLOCK1 STATEMENT is executed in BASIC. The interrupts associated with the CLOCK1 STATEMENT cause MCS BASIC-52 programs to run at about 99.6% of normal speed.

That means that the interrupt handling for the REAL TIME CLOCK feature only consumes about .4% of the total CPU time. This very small interrupt overhead is attributed to the very fast and effective interrupt handling of the 8052AH device. CLOCK0 The CLOCK0 (zero) STATEMENT disables or "turns off" the REAL TIME CLOCK feature. This statement clears bit 2 in the 8052AH's special function register, IE. After CLOCK0 is executed, the special function operator TIME will no longer increment. The CLOCK0 STATEMENT also returns control of the interrupts associated with TIMER COUNTER 0 back to the user, so this interrupt may be handled at the assembly language level.

CLOCK0 is the only MCS BASIC-52 statement that can disable the REAL TIME CLOCK. CLEAR and CLEARI will NOT disable the REAL TIME CLOCK. VARIATIONS: None. - 32 -