breeze
Joined: 22 Aug 2013 Posts: 2
|
CCS C, PIC18F67K22 ADC problem ? |
Posted: Fri Aug 23, 2013 3:55 am |
|
|
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
|
Re: CCS C, PIC18F67K22 ADC problem ? |
Posted: Fri Aug 23, 2013 4:11 am |
|
|
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
|
|
|