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

int e l 4.19 DESCRIPTION OF STATEMENTS STATEMENT: ONEX1 [ln num] MODE: RUN TYPE: CONTROL The ONEX1 [ln num] statement lets the user handle interrupts on the 8052AH's INT1 pin with a BASIC program. The line number following the ONEX1 statement tells the MCS BASIC-52 interpreter which line to pass control to when an interrupt occurs. In essence, the ONEX1 statement "forces" a GOSUB to the line number following the ONEX1 statement when the INT1 pin on the 8052AH is pulled low. The programmer must execute a RETI statement to exit from the ONEX1 interrupt routine. If this is not done all future interrupts on the INT1 pin will be "locked out" and ignored until a RETI is executed.

The ONEX1 statement sets bits 7 and 2 of the 8052AH's interrupt enable register IE. Before an interrupt can be processed, the MCS BASIC-52 interpreter must complete execution of the statement it is currently processing. Because of this, interrupt latency can vary from microseconds to tens of milliseconds. The ONTIME [expr], [ln num] interrupt has priority over the ONEX1 interrupt. So, the ONTIME interrupt can interrupt the ONEX1 interrupt routine. - 51 -