Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

AD with a 16F88??

Status
Not open for further replies.

Leeroy

New Member
G'day all.
I'm having some trouble getting an f88's internal AD to work.
I have gone over the data sheet and come up with the following code which dosn't work! But i don't know what i'm missing or doing wrong.

BCF STATUS, RP1
BCF STATUS, RP0
;
;
MOVLW B'00000001'
BSF STATUS, RP0
IORWF TRISA, F ;make bit 0 on port A input

MOVLW B'10000001'
MOVWF ADCON0 ; set Fosc/32, chanel 0 , AD on
MOVLW B'11000000'
MOVWF ADCON1 ; set right justified, /2 fosc, internal reference
MOVLW 1
MOVWF ANSEL ; set chanel 0
BCF PIE1, ADIE ; clear interupts


MOVLW 6;*
MOVWF AUX;*
NOP;*
PAGESEL (LAB_DLY_21);*
LAB_DLY_21;*
DECFSZ AUX;*
GOTO LAB_DLY_21;* ; 20 uS delay



BSF ADCON0, GO ;start conversion

ADCLAB1
BCF STATUS, RP1
BSF STATUS, RP0
PAGESEL (ADCLAB1)
BTFSC ADCON0, GO
GOTO ADCLAB1 ;wait till conversion is finished


MOVF ADRESL, W ;store result in var pulsetime2
BCF STATUS, RP0
MOVWF PULSETIME2_L
BSF STATUS, RP0
MOVF ADRESH, W
BCF STATUS, RP0
MOVWF PULSETIME2_H


I had written the entire application on a 16f877 on which the above AD code worked fine. But since porting back to the f88 i can't get it to work, the returned value in pulsetime2 is always 0..:confused:

Can anyone help?

Cheers

Leeroy
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top