>
> Thanks again,
>
> Mauricio Jancic
>
> -----Mensaje original-----
> De: Quitt, Walter [SMTP:
wquitt
KILLspamMICROJOIN.COM]
> Enviado el: Lunes, 13 de Diciembre de 1999 02:31 p.m.
> Para:
.....PICLISTKILLspam
.....MITVMA.MIT.EDU
> Asunto: Re: PIC17Cxxx Urgent HELP!!
>
> Here is a code snipet of how I have done it:
>
> ;***************************************************************
> ;* Read_Configuration
> ;*
> ;* Reads the configuration voltage to determine the number
> ;* of FETs or FET boards to determine system power level.
> ;* This uses Port G RG3:AN0 as an analog channel
> ;*
> ;* It also messes with other ports so must be done early
> ;* in/during init (pg 178)
> ;*
> ;* GLOBAL Interrupts MUST be OFF!
> ;* Since this is only called at init we can use software
> ;* loop timeouts for waiting for ADC conversions.
> ;*
> ;***************************************************************
> Read_Configuration
> ; ** First assume NO Configuration Fault ********************
> movlr STATES
> movlw FALSE
> movwf CONFIG_FAULT_STATE
>
> ; ** SETUP for ADC conversions ******************************
> movlb 5 ;Bank 5 is ADCON bank
>
> ; ** pg179 1. Config anlaog pins/ V ref, and digital I/O **
> movlw B'10101100' ;64T Clock select, output right justified,
> ; AN9,8,1,0 are inputs, A/D ref is AVdd and AVss
> movfp WREG,ADCON1 ;
>
> ; ** pg179 1. Select A/D input channel **
> movlw B'00000001' ;AN0,NO Conversion running, Converter is ON
> movfp WREG,ADCON0 ; NOTE: AN0 is Port G bit 3
>
> ; ** pg 179 3. Wait the required acquisition time **
> ; Recall 1 instruction is 4Q cycles = 4*1/28MHZ = 4*35ns = 140ns
> ; So 255 * 140ns is 35,700ns = 35us which is good enough
> ; for a Tacq as shown on pg181
> movlr 0
> movlw H'FF'
> movwf TEMP_0
> Read_Configuration_Wait_loop
> decfsz WREG,F
> goto Read_Configuration_Wait_loop
>
> ; ** pg179 4. Start Conversion **
> bsf ADCON0,GO
>
> ; ** pg179 5. Wait for A/D conversion to complete by polling GO/DONE
> **
> Read_Configuration_Wait
> btfsc ADCON0,GO
> goto Read_Configuration_Wait
>
> ; ** pg179 6. Read A/D result out of ADRESH and ADRESL in Bank 5 **
>