© 2001 Ubicom, Inc. All rights reserved. - 5 - www.ubicom.com Asynchronous Transmitter & Receiver (UART) Virtual Peripheral Implementation AN38 The source code of the interrupt service routine is shown below: ;*******************************************************************************
org
             INTERRUPT_ORG        ; First location in program memory.
;*******************************************************************************
;*******************************************************************************
;------------------------Interrupt Service Routine------------------------------
;*******************************************************************************
; Note: The interrupt code must always originate at address $0,
; Interrupt Frequency = (Cycle Frequency / -(retiw value))  For example:
; With a retiw value of -217 ;and an oscillator frequency of 50MHz, this
; code runs every 4.32us.
;*******************************************************************************
org     $0 ;*******************************************************************************
;------------------------VP:VP Multitasker--------------------------------------
;*******************************************************************************
; Virtual Peripheral Multitasker up to 16 individual threads, each running at
; the(interrupt rate/16).
; Input variable(s):isrmultiplex  : variable used to choose threads
; Output variable(s): None executes the next thread
; Variable(s) affected: isr_multiplex
; Flag(s) affected: None
; Program Cycles: 9 cycles (turbo mode)
;*******************************************************************************
              _bank MultiplexBank          ; inc isrMultiplex          ; toggle interrupt rate mov w,isrMultiplex        ; ;*******************************************************************************
; The code between the tableStart and tableEnd statements MUST be completely
; within the first half of a page. The routines it is jumping to must be in the
; same page as this table.
;*******************************************************************************
tableStart ; Start all tables with this macro                 jmp            pc+w ;                 jmp            isrThread1 ;                 jmp            isrThread2 ;                 jmp            isrThread3 ;                 jmp            isrThread4 ;                 jmp            isrThread1 ;                 jmp            isrThread5 ;                 jmp            isrThread6 ;                 jmp            isrThread7 ;                 jmp            isrThread1 ;                 jmp            isrThread8 ;                 jmp            isrThread9 ;                 jmp            isrThread10 ;                 jmp            isrThread1 ;                 jmp            isrThread11 ;                 jmp            isrThread12 ;                 jmp            isrThread13 ; tableEnd ; End all tables with this macro.