Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] ADC not working . Please help me

Status
Not open for further replies.

d@nny

Full Member level 5
Full Member level 5
Joined
May 28, 2011
Messages
246
Helped
11
Reputation
22
Reaction score
11
Trophy points
1,298
Activity points
3,238
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
 

Hi there,
1st: how you know it is not working? Are you debugging your code and looking for the registers on mplab? (I supposed you are using mplab) :)
2nd: I took a very quick view on your code but seams it not returning from wait0 call. I didn't saw a retlw instruction.
3rd: what is the fin: for? it will lock you code execution on endless loop with no instruction on that, ok?

Sorry for quick look and I hope I help you.
 
  • Like
Reactions: d@nny

    d@nny

    Points: 2
    Helpful Answer Positive Rating
Hi there,
1st: how you know it is not working? Are you debugging your code and looking for the registers on mplab? (I supposed you are using mplab) :)
2nd: I took a very quick view on your code but seams it not returning from wait0 call. I didn't saw a retlw instruction.
3rd: what is the fin: for? it will lock you code execution on endless loop with no instruction on that, ok?

Sorry for quick look and I hope I help you.

After adding return in wait0 it is now working ok :p
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top