CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

16F676 vs 16F684

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
arunkish



Joined: 23 Dec 2008
Posts: 83

View user's profile Send private message

16F676 vs 16F684
PostPosted: Tue Jan 04, 2011 6:32 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jan 04, 2011 6:44 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jan 04, 2011 1:08 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group