Wendy Moss
New Member
Hello. This is my first venture into this forum. I usually "play" with RF, but recently I re awoke my interest in PIC programming. I designed a simple oscilloscope Time and Voltage calibrator. Digital is relatively easy. I then went onto trying to use the Analogue inputs. This is where it gets complicated. I first tried using the 16F690. However The code seemed to refuse just to light ONE led. So after many tries I bought a 16F818.
I faithfully copied the Config statements, and the Operating code, to light 8 leds depending upon the DC Voltage. However I understand that code printed in the data sheets.. may.. not be accurate....... for the chip config I used ( H'30C7').
See below where I think it is wrong.. but where ??
;**EQUATES SECTION*******
TMRO EQU 1
STATUS EQU 3
PORTA EQU 5
PORTB EQU 6
PORTC EQU 7
ZEROBIT EQU 2
ADCON0 EQU H'1F'
ADCON1 EQU H'9F'
ADRES EQU H'1E'
CARRY EQU H'00'
TRISA EQU H'85'
TRISB EQU H'86'
TRISC EQU H'87'
OPTION_R EQU H'81'
OSCCON EQU H'8F'
COUNT EQU H'20'
list p=16F690 ; list directive to define processor
org 0x04
goto start
#include <p16F690.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
;********MAIN_PROG CODE
CBLOCK 0x20 ; Start Data Block
CounterA ; for time delay
CounterB ; "
CounterC ; "
ENDC ; End of Data Block
;
; *******************************************************************************
; * The Interrupt vector is at 0x04. *
; *******************************************************************************
start
;***************CONFIGURATION SECTION***********
BSF STATUS,5 ;SWITCH TO BASNK 1
MOVLW B'00000100' ; PORT A INPUTS
MOVWF TRISA
MOVLW B'00000110' ; A1 & 2 Analog in
MOVWF ADCON1 ; A0,A3 DIGITAL I/P
; MOVLW B'00000000' ; PORT C OUT
; MOVWF TRISC
BCF STATUS,5 ; BACK TO BANK 0
MOVLW B'00000001' ; TURNS ON A/D CONVERTER
MOVWF ADCON0 ; SELECTS CHAN AN0
MOVLW B'00000000' ; PORTC OUT
MOVWF TRISC
CLRF PORTA
CLRF PORTC
Your assistance would be gratefully accepted
I faithfully copied the Config statements, and the Operating code, to light 8 leds depending upon the DC Voltage. However I understand that code printed in the data sheets.. may.. not be accurate....... for the chip config I used ( H'30C7').
See below where I think it is wrong.. but where ??
;**EQUATES SECTION*******
TMRO EQU 1
STATUS EQU 3
PORTA EQU 5
PORTB EQU 6
PORTC EQU 7
ZEROBIT EQU 2
ADCON0 EQU H'1F'
ADCON1 EQU H'9F'
ADRES EQU H'1E'
CARRY EQU H'00'
TRISA EQU H'85'
TRISB EQU H'86'
TRISC EQU H'87'
OPTION_R EQU H'81'
OSCCON EQU H'8F'
COUNT EQU H'20'
list p=16F690 ; list directive to define processor
org 0x04
goto start
#include <p16F690.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
;********MAIN_PROG CODE
CBLOCK 0x20 ; Start Data Block
CounterA ; for time delay
CounterB ; "
CounterC ; "
ENDC ; End of Data Block
;
; *******************************************************************************
; * The Interrupt vector is at 0x04. *
; *******************************************************************************
start
;***************CONFIGURATION SECTION***********
BSF STATUS,5 ;SWITCH TO BASNK 1
MOVLW B'00000100' ; PORT A INPUTS
MOVWF TRISA
MOVLW B'00000110' ; A1 & 2 Analog in
MOVWF ADCON1 ; A0,A3 DIGITAL I/P
; MOVLW B'00000000' ; PORT C OUT
; MOVWF TRISC
BCF STATUS,5 ; BACK TO BANK 0
MOVLW B'00000001' ; TURNS ON A/D CONVERTER
MOVWF ADCON0 ; SELECTS CHAN AN0
MOVLW B'00000000' ; PORTC OUT
MOVWF TRISC
CLRF PORTA
CLRF PORTC
Your assistance would be gratefully accepted