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

PIC18F46K22 can't read past adc channel 15

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



Joined: 01 Mar 2010
Posts: 73

View user's profile Send private message

PIC18F46K22 can't read past adc channel 15
PostPosted: Thu Oct 18, 2012 2:47 pm     Reply with quote

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!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 18, 2012 2:56 pm     Reply with quote

This is in the forum archives. See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=45570
picj1984



Joined: 01 Mar 2010
Posts: 73

View user's profile Send private message

PostPosted: Thu Oct 18, 2012 2:59 pm     Reply with quote

thx!!!
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