Ambient
New Member
I am trying to finish this simple code for a project that I will be expanding later on. I can't seem to get the comparator C1 to actually work internally. I am hoping to get this done for tomorrow when I need it. Any ideas why this blasted thing is not working? It flashes once (from LED assertion in main) and will not go on again. This is basically just a night light for this stage of the project.
Pin 18 - 1Mohm pot for testing
Pin 19 - NC
RC3 is a diode and resister.
pullup on MCLR
That is the entire circuit at the moment. Thanks for any help guys. I know it is something stupid I am doing.
Pin 18 - 1Mohm pot for testing
Pin 19 - NC
RC3 is a diode and resister.
pullup on MCLR
That is the entire circuit at the moment. Thanks for any help guys. I know it is something stupid I am doing.
Code:
List p=16f690
include P16F690.INC
__CONFIG _CP_OFF & _CPD_OFF & _BOR_OFF & _PWRTE_ON & _WDT_OFF & _INTOSCIO & _MCLRE_ON & _FCMEN_OFF & _IESO_OFF;
errorlevel -302
;-----------------------VARIABLE REGISTER DEFINITIONS---------------------------
;w_temp EQU 0x70 ; variable used for context saving
status_temp EQU 0x71 ; variable used for context saving
pclath_temp EQU 0x72 ; variable used for context saving
RC3 EQU h'03'
RC6 EQU h'06'
;================================CODE==================================
org 0x0000
goto Initialize
;***************************Interrupt_Routine**************************
org 0x0004 ; interrupt vector location
bcf INTCON,T0IF
; btfsc PORTC,RC6 ;next line run if SW1 OFF (active low)
; retfie
btfss CM1CON0, C1OUT
bcf PORTC,RC3
btfsc CM1CON0,C1OUT
bsf PORTC,RC3
retfie
;***************************INITIALIZATION*****************************
Initialize
movlw b'00011000'
movwf STATUS ;BANK 0
movlw b'00000000'
movwf ADCON0 ;turns off ADC
movlw b'00111000'
movwf STATUS ;BANK 1
movlw b'01000001'
movwf OSCCON ;sets oscillator to 1MHz
movlw b'00000110'
movwf OPTION_REG ;enables Timer0, pullups A and B, 1:256 PS,
movlw b'00001011'
movwf TRISA ;PORTA I/O setup
movlw h'00'
movwf TRISB ;PORTB
movlw b'00000000'
movwf TRISC ;PORTC:RC4,5,6 mosfet drivers, RC0,1,2 audio input port (A/D in later C code)
movlw b'11011000'
movwf STATUS ;BANK 2
movlw b'00000011'
movwf ANSEL ;analog disable ANS2-ANS7, ANS0 Analog input
movlw b'00000000'
movwf ANSELH ;analog disable ANS8-ANS11
movlw b'10000100'
movwf CM1CON0 ;enable C1 internal, Vref internal
bcf CM2CON0,h'07' ;disable C2
; movlw b'00110011' ;sets C1+ fixed 0.6V Vref
; movwf VRCON
movlw b'10101000' ;sets C1- Vref to (VR<3:0>/24)*VDD
movwf VRCON
movlw b'00011000'
movwf STATUS ;BANK 0
movlw b'11100000'
movwf INTCON ;enable int, Timer0 int
main
bsf PORTC,RC3
NOP
NOP
GOTO $-2
end