'12f683 29.01.14 'Define SIMULATION_WAITMS_VALUE = 1 'SIMULATION ONLY Define CONF_WORD = 0x33c4 OSCCON = %01100000 'Internal 4MHz osc CMCON0 = 7 'Comparators off ANSEL = 0 'All digital 'AllDigitital What's the difference '0006' WPU = 0 'Internal pull-ups = off 'TRISIO = 0x00 ?????????? OPTION_REG.T0CS = 0 OPTION_REG = %10000000 TRISIO = %00000100 'GPIO,0-1-2-4-=LED, GPIO,3 =IN GPIO,5 unused TRISIO.0 = 0 'PIN 7 as RLED TRISIO.1 = 0 'PIN 6 as WLED TRISIO.2 = 0 'PIN 5 as GLED TRISIO.3 = 1 'PIN 5 as input (IN ONLY) TRISIO.4 = 0 'PIN 4 as LED TRISIO.5 = 0 GPIO = %00000000 'All outputs = 0 on boot T1CON = %00110000 '0x30 = 8:1, so thats 1MHz/8= 125KHz or 8uSec T1CON.T1OSCEN = 1 T1CON.TMR1ON = 1 T1CON.TMR1CS = 0 TMR1L = %11011100 '0xdc See note in interrupt TMR1H = %00001011 '0xfe originally 0x0B INTCON.T0IE = 0 INTCON.GIE = 1 INTCON.PEIE = 1 PIE1.TMR1IE = 1 PIR1.TMR1IF = 0 Dim t As Word Enable loop: WaitMs 10 Goto loop End On Interrupt Save System PIR1.TMR1IF = 0 t = t + 1 TMR1L = %11011100 'L + H = decimal 65536-62500=3036] = 8uSec*62500 = 0.5Sec==Count up from 3036 decimal To 65536 TMR1H = %00001011 '='Then roll over To 0000 Count And generate an Interrupt every 0.5sec Resume