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

int e l 7.2 EXAMPLES OF MANIPULATING SPECIAL FUNCTION VALUES Using the logical operators available in MCS BASIC-52. it is possible to write to or read from any byte of the special function registers that MCS BASIC-52 treats as a register pair: EXAMPLE: WRITING TO THE HIGH BYTE >TIMER0 = (TIMER0 .AND. 00FFH)+ INT(256*(USER BYTE)) EXAMPLE: WRITING TO THE LOW BYTE >TIMER0 = (TIMER0 .AND. 0FF00H) + (USER BYTE) EXAMPLE: READING HIGH BYTE >PH0. INT(TIMER0/256) EXAMPLE: READING LOW BYTE >PH0. TIMER0 .AND. 0FFH TIMER1 can function as the baud rate generator for MCS BASIC-52. To assign TIMER1 as the baud rate generator, the following instructions must be executed:

>TMOD = 32 - TIMER1 in auto reload mode >TIMER1 = 256*(256-(65536-RCAP2)/12) - load TIMER1 >T2CON = 0 - use TIMER1 as baud rate gen This sequence of instructions can be executed in either the direct mode or as part of a program. When TIMER1 is used as the baud rate generator. TIMER2 can be used in anyway suitable to the application. The PROG, FPROG, LIST#, PRINT# and PWM commands/statements cannot be used when TIMER1 functions as the baud rate generator for the MCS BASIC-52 device. Certain crystals may not be able to use TIMER1 as the baud rate generator, especially at high (above 2400) baud rates. - 94 -