16F877A Problema para convertir A/D

Hola

Tengo un 16F877A y estoy haciendo pruebas infructuosas para convertir un voltaje que entra por AN0 en digital, el voltaje est=E1 en un rango

4,20~5,00 v.

Cuando energizo el PIC, los 10 bits de ADRH y ADRL quedan en alto aunque cambie el voltaje de AN0. Escrib=ED el procedimiento de adquisici=F3n como indica el datasheet, y estoy en un punto muerto, no se por donde continuar.

El proceso que realizo es el siguiente:

ADbyte_bajo equ 0x23 ADbyte_alto equ 0x24

Dormir nop call TestBateria call Tmp100us ; retardo 100 useg goto Dormir

TestBateria bcf STATUS, RP1 bsf STATUS, RP0 bsf ADCON1, PCFG3 bsf ADCON1, PCFG2 bsf ADCON1, PCFG1 bcf ADCON1, PCFG0 bcf ADCON1, ADFM bcf STATUS, RP1 bcf STATUS, RP0 bcf ADCON0, CHS2 bcf ADCON0, CHS1 bcf ADCON0, CHS0 bcf STATUS, RP1 bsf STATUS, RP0 bsf ADCON1, ADCS2 bcf STATUS, RP1 bcf STATUS, RP0 bsf ADCON0, ADCS1 bsf ADCON0, ADCS0 bsf ADCON0, ADON bcf PIR1, ADIF bsf PIE1, ADIE call Tmp25us ; retardo 25 useg bsf ADCON0, GO_DONE return

; atenci=F3n de la int SDI btfss PIR1, ADIF goto SDI_Fin_AD movlw ADRESH movwf ADbyte_alto movlw ADRESL movwf ADbyte_bajo bcf PIR1, ADIF call EscrBatLed retfie

ADbyte_alto y ADbyte_bajo los escribo en RC y RD (pines 21 a 30)

Muchisimas gracias por cualquier ayuda o pista.

Saludos.-

Reply to
LucasBols
Loading thread data ...

Lo solucion=E9

El =FAnico problema que me queda es ver por que inyectando 4,09v en AN0 me entrega 239 en lugar de entregarme 1023 Supongo que debe andar por el lado de la tensi=F3n de referencia, sin embargo, indico que vref+ =3D vdd y vref- =3D vss por que configuro PCFG3:PCFG0 con 1110, que configura AN7:AN0 como D D D D D D D A, vref

  • =3D vdd y vref- =3D vss.

Deber=EDa inyectar vref+/- por alg=FAn RA con valores 4,50v y 5,00v, pero me quedar=EDa m=E1s de un puerto como anal=F3gico, y en este proyecto, no puedo prescindir de ning=FAn puerto.

Este es el resultado. ;##########################################################################= #### ; Salida de Bater=EDa AN0 Decimal Binario ; M=EDnimo 11,50 v 4,50 v 225 ~ 226 0011100001 ~ 0011100010 ; M=E1ximo 13,10 v 4,09 v 238 ~ 239 0011101110 ~ 0011101111 ;##########################################################################= #### ; CABECERA **** ;************** list p=3DP16F877A ; list directive to define processor #include ; processor specific variable definitions

;--------------------------------------------------------------------------=

--
	__CONFIG _XT_OSC & _DEBUG_OFF & _WDT_OFF & _PWRTE_OFF & _BODEN_OFF &
_LVP_OFF & _CPD_OFF & _CP_OFF & _DEBUG_OFF
 Click to see the full signature
Reply to
LucasBols

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.