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

pic18f24k22 impossible to set an channel 16, 17, 18 ,19

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



Joined: 11 May 2009
Posts: 22

View user's profile Send private message

pic18f24k22 impossible to set an channel 16, 17, 18 ,19
PostPosted: Fri Jun 03, 2011 12:41 pm     Reply with quote

Hi, I'm using a pic18f24k22. When I use the set_adc_channel function it work great with all analog channels from an0 to an15, when I set a channel greater than 15 it doesn't work.
I've noticed that analog channel greater than 15 use 5 bit for setup the channel in the ADCON0 register.
How I can fix the problem?
Is it possible to modify function set_adc_channel?

I've pcwhd 4.120
thanks to all.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 03, 2011 12:46 pm     Reply with quote

Post a short but complete test program that shows your problem.
The program should look very similar to the one in the link below,
but modify it to show your problem:
http://www.ccsinfo.com/forum/viewtopic.php?t=44709&start=11
blo



Joined: 11 May 2009
Posts: 22

View user's profile Send private message

PostPosted: Fri Jun 03, 2011 12:57 pm     Reply with quote

The problem is that pcwhd has a bug in the setup_adc_ports() function that cannot permit the external positive voltage reference.
And it has another bug in the set_adc_channel() function that cannot permit you to set the 6th bit of the ADCON0 register. So it work fine between an0 and an15 channel, but cannot set greater channel of adc.
Now i set manually the two register and it works.

where i can find the set_adc_channel function so i can modify the function?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 03, 2011 1:25 pm     Reply with quote

CCS doesn't give the source code for that function.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 06, 2011 12:25 pm     Reply with quote

Quote:
Where i can find the set_adc_channel function so i can modify the function?

I just wrote a macro for that PIC family for that function. The compiler will
substitute the (working) macro code for the buggy built-in function. See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=45570
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