Programming the PIC Microcontroller with MBasic

What are interrupts? What are timers? How are they related? And, why should an MBasic programmer care?
An interrupt is an event that causes the current program sequence to temporarily halt, and for different code, called an "interrupt service routine" or ISR, to be executed. After the ISR completes, program flow returns to the point it was at before the interrupt occurred. You might think of an ISR as a subroutine that is called not by a GoSub in software, but rather an event. The event may be external, such as an input pin changing state from a 0 to a 1, or vice versa. Or, the event may be internal to the PIC, such as a timer reaching a defined count. It may even be a combination of external and internal events, such as where repeated external signals cause an internal counter to reach a preset value.
This chapter focuses on ISRs written purely in MBasic. As we'll learn, an ISR written in MBasic has one significant restriction it will be executed only "between" other MBasic statements. In some cases, this latency is a serious drawback. For example, if our program is waiting for an input string in a SerIn statement, and an interrupt occurs, the ISR will not be executed until the SerIn statement completes, thereby negating the benefit of an interrupt. If a Pause 1000 statement is executed, the MBasic ISR will not be executed until the