>> As long as I account for capacitor charge time, can I turn the A/D off
>> and on at will? Right now I just leave it on...
>>
>> The first line in AD_RA0() leaves the A/D enabled for the life of the
>app.
>> The second line does a delay for A/D capacitor charge time before ADGO.
>> I've placed a comment where I wonder if I could/should turn the A/D off.
>>
>> - Bri
>>
>>
>> void AD_init(void)
>> {
>> OPTION = 0x87; // Set TMR0 prescaler, and 1:256
>> ADCON1 = 0x02; // Left justify result, 3 analog channels
>> }
>>
>> unsigned char AD_RA0(void)
>> {
>> ADCON0 = 0x41; // Fosc/8, A/D enabled
>> DelayUs(20); // Allow time for A/D capacitor to charge
>> ADGO = 1; // Set the bit to start the conversion
>> while (ADGO) // Wait for the conversion to complete
>> continue; //
>> //// could/should disable A/D here? (w/ADCON0)
>> return ADRESH; // Return the AD value (just the top 8 bits)
>> }
>
>I see no reason you couldn't turn it off as long as you observer all the
>rules when turning it back on again. I've never done it this way. Why do
>you want to turn off the A/D? will you not use it again or are you trying
>to save power?
>
>
>********************************************************************
>Olin Lathrop, embedded systems consultant in Littleton Massachusetts
>(978) 742-9014,
olin
spam_OUTembedinc.com, http://www.embedinc.com
>
9