'**************************************************************** '* Name : Timer1code.BAS * '* Author : Chuck Hellebuyck * '* Notice : Copyright (c) 2006 * '* : All Rights Reserved * '* Date : 2/9/2006 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** ' DEFINE LOADER_USED 1 ' This command line for Ultimate OEM only DEFINE OSC 20 counter var byte 'Establish a byte size variable TMR1H = $0B 'Preset Timer 1 to 3035 TMR1L = $DB ' using $0BDB hex T1CON = %00110001 'Timer1 on with 1:8 prescaler PIE1 = %00000001 'Enable Timer1 Interrupt INTCON = $C0 ON INTERRUPT GOTO mytimer 'Enable interrupts and handler high 2 'Initialize B2 LED to on counter =0 main if counter = 10 then 'Test for 10 interrupts toggle 2 '10 interrupts occurred so flip LED state counter = 0 'Reset counter variable endif 'End the If-Then command goto main 'Loop back to the Beginning '*** This is where we go on and interrupt *** disable 'Prevent interrupts from occurring mytimer: 'Interrupt handler routine label TMR1H = $0B 'Preset Timer 1 to 3035 decimal TMR1L = $DB ' using $0BDB hex counter = counter +1 'Increment the timer overflow count PIR1.0 = 0 'Clear Timer1 overflow interrupt flag resume 'This is how we exit an interrupt