As you could see in my program("@ device intrc_osc_noclkout" and "PCON.3=1") , I am using the built-in 4MHz internal OSC .The one you see on the schematic was the one that I used for the real time clock on Tmr1 (32.768khz). You will find below the device setup that I used for quick reference.
Could you please tell me those errors that you saw in the schematic ? I some times have second thought about mixing the digital circuit with the main power (ACS108). I found an error in the schematic and corrected it.The collector part of the phototransistor was connected to the Gnd. It should have been connected to the +ve.The new schematic is attached.
DEFINE INTHAND myint
@ device intrc_osc_noclkout
@ device wdt_off
@ device lvp_off
@ device pwrt_on
@ device cpd_off
@ device bod_off
@ device mclr_off
@ device PROTECT_OFF
' **************
' *Device setup*
' **************
PIE1.6 = 0 'disable the comparator before mesing with cmcon & vrcon
VRCON = %10001011 'Voltage Refernece enabled and voltage = 2.97
pause 10 'for stabiliazing
CMCON = %10000101 'Single comparator enabled RA0 & RA3 are free for I/O
PAUSE 10
PIR1.6 = 0 'clear residing interrupt flag
PIE1.6 = 1 'enable comparator flag
pcon.3=1 '1=Internal oscillator 4mhz ,0=37khz
T1con =%00001111 ' Turn on Timer1 with prescaler = 1
Pir1.0 = 0 'disable comp & timr1 int flag
trisb = %00000001
trisa = %10100110 'PortA 1&2 are analog input ,the rest are digital I/O
PIE1.0 = 1 ' Enable TMR1 overflow and Comparator interrupt
INTCON = %11010000 ' Enable global ,peripheral , external interrupts
Bookmarks