d@nny
Full Member level 5
hello!
i am learning adc from gooligum tutorial but i cant make ADC. I am using the following code for this but cant see any result
processor PIC16F819
#include <p16f819.inc>
__CONFIG _CP_OFF & _WRT_ENABLE_OFF & _CPD_OFF & _CCP1_RB2 & _LVP_OFF & _BODEN_ON & _MCLR_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_IO
J equ 21h
K equ 22h
org 0x00
goto main
main:
banksel OSCCON
movlw B'01110000'
movwf OSCCON
banksel PORTA
clrf PORTA
banksel PORTB
clrf PORTB
banksel ADCON1
movlw b'00001110'
movwf ADCON1
BANKSEL ADCON0
movlw b'11000001'
movwf ADCON0
banksel TRISA
movlw B'00010001'
movwf TRISA
banksel TRISB
movlw B'00000000'
movwf TRISB
loop:
call wait0
banksel ADCON0
bsf ADCON0 , 2
wait: btfsc ADCON0 , 2
goto wait
banksel ADRESL
movf ADRESL , 0
banksel PORTB
movwf PORTB
goto loop
wait0:
movlw D'1'
movwf K
clrf J
delay1:
nop
decfsz J , f
goto delay1
delay2:
nop
decfsz J , f
goto delay2
decfsz K , f
goto delay1
fin:
goto fin
end
Please help me
i am learning adc from gooligum tutorial but i cant make ADC. I am using the following code for this but cant see any result
processor PIC16F819
#include <p16f819.inc>
__CONFIG _CP_OFF & _WRT_ENABLE_OFF & _CPD_OFF & _CCP1_RB2 & _LVP_OFF & _BODEN_ON & _MCLR_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_IO
J equ 21h
K equ 22h
org 0x00
goto main
main:
banksel OSCCON
movlw B'01110000'
movwf OSCCON
banksel PORTA
clrf PORTA
banksel PORTB
clrf PORTB
banksel ADCON1
movlw b'00001110'
movwf ADCON1
BANKSEL ADCON0
movlw b'11000001'
movwf ADCON0
banksel TRISA
movlw B'00010001'
movwf TRISA
banksel TRISB
movlw B'00000000'
movwf TRISB
loop:
call wait0
banksel ADCON0
bsf ADCON0 , 2
wait: btfsc ADCON0 , 2
goto wait
banksel ADRESL
movf ADRESL , 0
banksel PORTB
movwf PORTB
goto loop
wait0:
movlw D'1'
movwf K
clrf J
delay1:
nop
decfsz J , f
goto delay1
delay2:
nop
decfsz J , f
goto delay2
decfsz K , f
goto delay1
fin:
goto fin
end
Please help me