Hi
Wish you all a happy new year. I have been reading ADC with 16F676 without any problem. I migrated to new controller 16F684 and used the same code to read the ADC. I am getting a value that is nearly 200 times higher than what I get in 16F676. setting #deivce adc=8 did not help. Is there anything that I should do more to make it work with 16F684.
Thanks & Regards
arunkish
Joined: 23 Dec 2008 Posts: 83
Posted: Tue Jan 04, 2011 6:44 am
Sorry forgot to tell how I had setup things..
in main:
Code:
setup_adc_ports(sAN0);
void readadc(void)
{
int value;
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
delay_ms(5);
value=read_adc();
}
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Tue Jan 04, 2011 1:08 pm
Quote:
void readadc(void)
{
int value;
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
delay_ms(5);
value=read_adc();
}
The internal ADC clock is not recommended for normal use by the
16F684 data sheet. Look in the following section of the data sheet:
Quote:
9.1.4 CONVERSION CLOCK
TABLE 9-1: ADC CLOCK PERIOD (TAD) VS. DEVICE OPERATING FREQUENCIES (VDD > 3.0V)
It shows the recommended ADC clock divisor to use for each PIC
oscillator frequency. For example, if you have a 4 MHz crystal, then
use Fosc/8. The CCS constant for this is ADC_CLOCK_DIV_8.
For 8 MHz oscillator, use ADC_CLOCK_DIV_16, etc. Look in the table
in the data sheet.
If that doesn't solve your problem, then post a small compilable test
program and post your compiler version.
Also post a description of the external circuit which is connected to the
A/D input of your PIC.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum