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..
Can anyone help?
Cheers
Leeroy
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..
Can anyone help?
Cheers
Leeroy