piclist 2000\11\14\122548a >
Thread: PIC12C671 A/D
www.piclist.com/techref/microchip/ios.htm?key=a%2Fd
flavicon
face BY : Dan Michaels email (remove spam text)



Try putting a < GOTO START > ahead of the < MAIN > label, and
see if that helps. Also, you might move your variable declarations
ahead of the ORG statement.

- danM
===================


akhifra wrote:

Hi, the following is A/D code for a PIC12C671.  I disabled all interrupts
based on the assumption that you do not need them for simple A/D.  Can some
one please trouble shoot this code for me please?  I am planning controlling a
couple of DC motors using the PIC12C671, but first I need the A/D to work.
Thanks
Fraidun

       LIST    P=12C671
       INCLUDE <P12C671.INC>
       ORG     0X00                    ;PROGRAM STARTING POINT
       VARIABLE RESULT                 ;TEMPERARY VARIABLE
       BCF     STATUS, RP0             ;GO TO BANK 0
       BCF     PIR1, ADIF              ;A/D NOT CONPLETE
       BSF     STATUS, RP0             ;GO TO BANK 1
       BCF     PIE1, ADIE              ;A/D INTERRUPT DISABLED
       CLRF    INTCON                  ;DISABLE ALL INTERRUPTS
       BCF     TRISIO, 1               ;CLEARS TRIS OF GPIO.1
       BSF     TRISIO, 0               ;SETS TRIS OF GPIO.0
       CLRF    ADCON1                  ;INITIALIZE ADCON1
       BSF     ADCON1, 1
       BSF     ADCON1, 2               ;ALL PINS DIGITAL EXCEPT GP0
START
       BCF     STATUS, RP0
       CALL    MAIN
       MOVFW   RESULT
       ANDLW   B'00000010'             ;SCREEN OUT ALL BUT GPIO.1
       MOVWF   GPIO                    ;VALUE TO OUTPUT PIN GPIO.1
MAIN
       CLRF    ADCON0                  ;INITIALIZE ADCON0
       BSF     ADCON0, 0               ;A/D MODULE STARTS TO CONDUCT
       BSF     ADCON0, 7
       BSF     ADCON0, 6               ;FREQ SET TO HIGHEST LEVEL
       CALL    FIND
       MOVLW   ADRES
       MOVWF   RESULT                  ;RESULT OF A/D TO RESULT
       RETURN
FIND
       BSF     ADCON0, 3               ;STARTS A/D BY TURNING ON GO/DONE BIT
LOOP
       BTFSC   ADCON0, 3               ;WAITS UNTILL CONVERSION IS COMPLETE
(GO/DONE = 0)
       GOTO    LOOP
       RETURN
       END

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


<1.5.4.16.20001114102630.363721d8@pop.dnvr.uswest.net>

See also: www.piclist.com/techref/microchip/ios.htm?key=a%2Fd
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) PIC12C671 A/D

month overview.

new search...