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

int e l 7.1 SPECIAL FUNCTION OPERATORS TIME The TIME operator is used to retrieve and/or assign a value to the REAL TIME CLOCK resident in MCS BASIC-52. After reset, TIME is equal to 0. The CLOCK1 statement enables the REAL TIME CLOCK. When the REAL TIME CLOCK is enabled, the SPECIAL FUNCTION OPERATOR, TIME will increment once every 5 milliseconds. The TIME operator uses TIMER0 and the interrupts associated with TIMER0 on the 8052AH. The unit of TIME is seconds and the appropriate XTAL value must be assigned to insure that the TIME operator is accurate. When TIME is assigned a value with a LET statement (i.e. TIME = 100), only the integer portion of TIME will be changed. EXAMPLE:

>CLOCK1 (enable REAL TIME CLOCK) >CLOCK0 (disable REAL TIME CLOCK) >PRINT TIME (display TIME) 3.315 >TIME = 0 (set TIME = 0) >PRINT TIME (display TIME) .315 (only the integer is changed) The "fraction" portion of TIME can be changed by manipulating the contents of internal memory location 71 (47H). This is accomplished by a DBY(71) statement. Note that each count in internal memory location 71 (47H) represents 5 milliseconds of TIME. Continuing with the EXAMPLE: >DBY(71) = 0 (fraction of TIME = 0) >PRINT TIME 0 >DBY(71) = 3 (fraction of TIME = 3, 15 ms) >PRINT TIME 1.5 E-2 - 91 -