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 support@ccsinfo.com

CCS C, PIC18F67K22 ADC problem ?

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



Joined: 22 Aug 2013
Posts: 2

View user's profile Send private message Send e-mail

CCS C, PIC18F67K22 ADC problem ?
PostPosted: Fri Aug 23, 2013 3:55 am     Reply with quote

Hi, guys.

I'm trying to get a ADC value from AN0 pin with PIC18F67K22.
PIC18F67K22 has 12bit ADC module.

c code with CCS C.

#DEVICE PIC18F67K22 ADC=12

main()
{
unsigned int adc_value=0;
setup_adc_ports(sAN0, VSS_VDD ); // VDD=5V, VSS=GND
setup_adc(ADC_CLOCK_INTERNAL); //
set_adc_channel(0);
delay_ms(100);

adc_value = read_adc();
printf("adc0 = %4X , ", adc_value};
}

then, outptut of printf() is adc0=0079;
BTW, ADRESH = CDh, ADRESL = 79, it means adc0 = ADRESL.
why adc_value doesn't include ADRESH value ?

please help me.
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

Re: CCS C, PIC18F67K22 ADC problem ?
PostPosted: Fri Aug 23, 2013 4:11 am     Reply with quote

breeze wrote:

#DEVICE PIC18F67K22 ADC=12


This is wrong. You need to specify the PIC first by including the device header file, then the #device stuff on separate lines. The device header file has a "#device PIC18F6722" line as its first non-comment line. Like this:

Code:

#include <18F67K22.h>
#device adc=12
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