Searching \ for '[PIC]: PIC12C671 A/D' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=a%2Fd
Search entire site for: 'PIC12C671 A/D'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: PIC12C671 A/D'
2000\11\13@212418 by akhifra

picon face
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: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2000\11\14@122548 by Dan Michaels

flavicon
face
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


2000\11\14@164054 by akhifra

picon face
I MADE THOSE CHANGES TO MY A/D CODE AND THE CHIP IS STILL NOT RESPONDING TO MY
INPUTS.  HERE IS THE NEW CODE, PLEASE FEEL FREE TO GIVE ME SOME INPUTS:

LIST    P=12C671
INCLUDE <P12C671.INC>
VARIABLE RESULT
ORG     0X00
BCF     STATUS, RP0
BCF     PIR1, ADIF
BSF     STATUS, RP0
BCF     PIE1, ADIE
CLRF    INTCON
BCF     TRISIO, 1
BSF     TRISIO, 0
CLRF    ADCON1
BSF     ADCON1, 1
BSF     ADCON1, 2
START
BCF     STATUS, RP0
CALL    MAIN
MOVFW   RESULT
ANDLW   B'00000010'
MOVWF   GPIO
GOTO    START
MAIN
CLRF    ADCON0
BSF     ADCON0, 0
BSF     ADCON0, 7
BSF     ADCON0, 6
CALL    FIND
MOVLW   ADRES
MOVWF   RESULT
RETURN
FIND
BSF     ADCON0, 2
LOOP
BTFSC   ADCON0, 2
GOTO    LOOP
RETURN
END

THE CODE ASSEMBLES WELL ON MPLAB, ITS JUST THAT IT DOESN'T WORK WHEN ON THE
CHIP.
THANKS
FRAIDUN


>===== Original Message From pic microcontroller discussion list
<spam_OUTPICLISTTakeThisOuTspammitvma.mit.edu> =====
{Quote hidden}

--
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


2000\11\14@164510 by Tony Nixon

flavicon
picon face
>         MOVLW   ADRES
>         MOVWF   RESULT                  ;RESULT OF A/D TO RESULT
>         RETURN


Try...

       movf ADRES,W
       movwf RESULT
       return

--
Best regards

Tony

mICro's
http://www.picnpoke.com
.....salesKILLspamspam@spam@picnpoke.com

--
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


2000\11\14@165751 by Bob Ammerman

picon face
See my notes below.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

{Original Message removed}

2000\11\14@185942 by akhifra

picon face
THanks for the help guys, here is where I am now and still no luck.
LIST    P=12C671
       INCLUDE <P12C671.INC>
       CBLOCK  0X60
               RESULT
       ENDC
       ORG     0X00
       BCF     STATUS, RP0
       BCF     PIR1, ADIF
       BSF     STATUS, RP0
       BCF     PIE1, ADIE
       CLRF    INTCON
       BCF     TRISIO, 1
       BSF     TRISIO, 0
       CLRF    ADCON1
       BSF     ADCON1, PCFG1
       BSF     ADCON1, PCFG2

START
       BCF     STATUS, RP0
       CLRF    GPIO
       BSF     GPIO, 0
       CALL    MAIN
       MOVFW   RESULT
       ANDLW   B'00000010'
       MOVWF   GPIO
       GOTO    START
MAIN
       CLRF    ADCON0
       BSF     ADCON0, ADON
       BSF     ADCON0, ADCS1
       BSF     ADCON0, ADCS2
       CALL    FIND
       MOVF    ADRES, W
       MOVWF   RESULT
       RETURN
FIND
       BSF     ADCON0, GO
LOOP
       BTFSC   ADCON0, GO
       GOTO    LOOP
       RETURN
       END

I apreciate all the help.  Thanks
Fraidun





>===== Original Message From pic microcontroller discussion list
<PICLISTspamKILLspammitvma.mit.edu> =====
>See my notes below.
>
>Bob Ammerman
>RAm Systems
>(contract development of high performance, high function, low-level
>software)
>
>{Original Message removed}

2000\11\14@194318 by Tony Nixon

flavicon
picon face
akhifra wrote:

Try this..

I am assuming you are reading from analog CH 0.

       LIST    P=12C671
       INCLUDE <P12C671.INC>

       CBLOCK  0X20

         TEMP
         RESULT

       ENDC

       ORG 0x0000



       BSF STATUS, RP0    ; RAM PAGE 1

       ; I NOTICE YOU HAVE NOT USED AN OSCAL VALUE ???

;       MOVLW XXh          ; SET OSCAL VALUE
;       MOVWF OSCAL

       MOVLW b'11010000'  ; NO PULLUPS, TMR0 INTERNAL, 1:2
       MOVWF OPTION_REG
       CLRF GPIO          ; ALL PINS = LO
       MOVLW B'00000001'  ; MAKE SURE UNUSED PINS = OUTPUTS
       MOVWF TRISIO       ; RA0 = INPUT FOR A2D
       MOVLW B'00000110'  ; CH0 = ANALOG, NO VREF
       MOVWF ADCON1
       BCF STATUS,RP0     ; RAM PAGE 0
       MOVLW B'10000001'  ; Fosc/32, CH 0, A2D = ON
       MOVWF ADCON0
       CLRF INTCON        ; CLEAR T0IF FLAG

       CLRF TEMP          ; WAIT A BIT UNTIL PORTS AND A2D
WAIT    NOP                ; CONVERTER STABILIZE
       BTFSS INTCON,T0IF
       GOTO WAIT

       DECFSZ TEMP
       GOTO WAIT

; MAIN LOOP

START   CALL FIND          ; A2D RESULT IN RESULT
       MOVF RESULT,W
       MOVWF GPIO         ; WRITE DATA TO PORT

       ; MAYBE A SMAL DELAY HERE

       GOTO START

FIND    BSF ADCON0,GO
LOOP    NOP
       BTFSC ADCON0,GO
       GOTO LOOP

       MOVF ADRES,W
       MOVWF RESULT
       RETURN

       END

--
Best regards

Tony

mICro's
http://www.picnpoke.com
.....salesKILLspamspam.....picnpoke.com

--
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


2000\11\14@200130 by Dan Michaels

flavicon
face
akhifra wrote:
>THanks for the help guys, here is where I am now and still no luck.


Don't know if you have tried it yet, but maybe your PIC
just is not working at all. You might try something simple
like just programming a pin to output 1 and 0, and loop.
Get to to go, then try more complicated stuff.

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

{Quote hidden}

>>{Original Message removed}

2000\11\14@200140 by Tony Nixon

flavicon
picon face
Tony Nixon wrote:

Man, I'm having a bad day...

The CLRF GPIO was in the wrong spot.


       ORG 0x0000

       CLRF GPIO          ; ALL PINS = LO <<<<<<<<
       BSF STATUS, RP0    ; RAM PAGE 1

       ; I NOTICE YOU HAVE NOT USED AN OSCAL VALUE ???

;       MOVLW XXh          ; SET OSCAL VALUE
;       MOVWF OSCAL

       MOVLW b'11010000'  ; NO PULLUPS, TMR0 INTERNAL, 1:2
       MOVWF OPTION_REG
       ....

--
Best regards

Tony

mICro's
http://www.picnpoke.com
salesspamspam_OUTpicnpoke.com

--
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


More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...