chrisdagger
New Member
Hi folks!
I'm hoping someone will be able to help me here because I'm lost! I have a thermistor connected to AN1 of the 16F914, and I'm trying to take a reading... basically, LED turns either blue or red depending on the bits in the ADRESH register (left justified). Or at least, that is the plan. Only I'm getting both blue and red LEDs illuminated at the same time on power up, until I disconnect and reconnect the thermistor in the circuit, or the 22k resistor betweek AN1 and GND. I have configured Fosc/8 for a 4MHz internal clock, as defined by the datasheet.
I feel like I'm missing something vital. I have copied / pasted the code below!
The other question I have, about the ULN2003A... I'm planning to use this to drive LEDs, as I plan to use pretty much all available outputs of the 16F914 to drive LEDs, and I'm pretty sure that it might not be capable without a driver, such as the ULN2003A. I have a numbe of ULN2003AG's, and wondered what the "G" stood for. Are the pinouts different? I have connected the device as I would a ULN2003A, and it doesn't work. My logic probe says the outputs are correct, voltage wise, but the LEDs will not illuminate.
Thanks in advance!!!
Chris
Configs
START
;SET PORTB O/P
BSF STATUS,5
CLRF PORTB
MOVLW B'00000000' ; ALL O/P
MOVWF TRISB
;CONFIG OSC
MOVLW B'01100101' ; SELECT 4MHZ INTOSC. REST DEFINED BY CONFIG WORD
MOVWF OSCCON
;CONFIG ADC BITS IN BANK 1
MOVLW B'00010000' ;ADC CLOCK SELECT Fosc/8
MOVWF ADCON1
BCF STATUS,5
;CONFIG ADC
MOVLW B'00000100' ;AN1 ANALOGUE I/P
MOVWF ADCON0
BSF ADCON0,0 ;SWITCH ON ADC
Taking measurement
MAINLOOP BSF ADCON0,1 ;TAKE AD MEASUREMENT
WAIT BTFSC ADCON0,1 ;WAIT UNTIL GO/DONE IS CLEAR
GOTO WAIT
;TEST TEMP
RESULT1 BTFSS ADRESH,7
GOTO RESULT2
GOTO RESULTHOT
RESULT2 BTFSS ADRESH,6
GOTO RESULT3
GOTO RESULTHOT
RESULT3 BTFSS ADRESH,5
GOTO RESULT4
GOTO RESULTHOT
RESULT4 BTFSS ADRESH,4
GOTO RESULTCOLD
RESULTHOT CLRF ADRESH
CALL RED
GOTO MAINLOOP
RESULTCOLD CLRF ADRESH
CALL BLUE
GOTO MAINLOOP
I'm hoping someone will be able to help me here because I'm lost! I have a thermistor connected to AN1 of the 16F914, and I'm trying to take a reading... basically, LED turns either blue or red depending on the bits in the ADRESH register (left justified). Or at least, that is the plan. Only I'm getting both blue and red LEDs illuminated at the same time on power up, until I disconnect and reconnect the thermistor in the circuit, or the 22k resistor betweek AN1 and GND. I have configured Fosc/8 for a 4MHz internal clock, as defined by the datasheet.
I feel like I'm missing something vital. I have copied / pasted the code below!
The other question I have, about the ULN2003A... I'm planning to use this to drive LEDs, as I plan to use pretty much all available outputs of the 16F914 to drive LEDs, and I'm pretty sure that it might not be capable without a driver, such as the ULN2003A. I have a numbe of ULN2003AG's, and wondered what the "G" stood for. Are the pinouts different? I have connected the device as I would a ULN2003A, and it doesn't work. My logic probe says the outputs are correct, voltage wise, but the LEDs will not illuminate.
Thanks in advance!!!
Chris
Configs
START
;SET PORTB O/P
BSF STATUS,5
CLRF PORTB
MOVLW B'00000000' ; ALL O/P
MOVWF TRISB
;CONFIG OSC
MOVLW B'01100101' ; SELECT 4MHZ INTOSC. REST DEFINED BY CONFIG WORD
MOVWF OSCCON
;CONFIG ADC BITS IN BANK 1
MOVLW B'00010000' ;ADC CLOCK SELECT Fosc/8
MOVWF ADCON1
BCF STATUS,5
;CONFIG ADC
MOVLW B'00000100' ;AN1 ANALOGUE I/P
MOVWF ADCON0
BSF ADCON0,0 ;SWITCH ON ADC
Taking measurement
MAINLOOP BSF ADCON0,1 ;TAKE AD MEASUREMENT
WAIT BTFSC ADCON0,1 ;WAIT UNTIL GO/DONE IS CLEAR
GOTO WAIT
;TEST TEMP
RESULT1 BTFSS ADRESH,7
GOTO RESULT2
GOTO RESULTHOT
RESULT2 BTFSS ADRESH,6
GOTO RESULT3
GOTO RESULTHOT
RESULT3 BTFSS ADRESH,5
GOTO RESULT4
GOTO RESULTHOT
RESULT4 BTFSS ADRESH,4
GOTO RESULTCOLD
RESULTHOT CLRF ADRESH
CALL RED
GOTO MAINLOOP
RESULTCOLD CLRF ADRESH
CALL BLUE
GOTO MAINLOOP