picj1984
Joined: 01 Mar 2010 Posts: 73
|
PIC18F46K22 can't read past adc channel 15 |
Posted: Thu Oct 18, 2012 2:47 pm |
|
|
Hello,
I'm using a PIC18F46K22, compiler version 4.121. I am finding that if I try to set the ADC channel to 16 or higher, it rolls over to channel 0, and so on. For example, channel 16 actually sets to 0, channel 17 to 1, channel 18 to 2, etc.
Here is my streamlined example:
Code: |
#include <18F46K22.h>
#fuses INTRC_IO,NOWDT,PUT,BROWNOUT,NOLVP
#device ADC=10
#device ICD=TRUE
#use delay(clock=16000000, int)
unsigned long int value = 0;
void main ()
{
setup_adc_ports(sAN16);
setup_adc(ADC_CLOCK_DIV_16);
set_adc_channel(16);
while(1)
{
delay_ms(1000);
value = read_adc();
}
}
|
For some reason, this code reads adc channel 0... pin 2. I'm expecting it to read adc channel 16, pin c4.
THANK YOU IN ADVANCE OR ANY HELP OR INSIGHT!! |
|