View previous topic :: View next topic |
Author |
Message |
blo
Joined: 11 May 2009 Posts: 22
|
pic18f24k22 impossible to set an channel 16, 17, 18 ,19 |
Posted: Fri Jun 03, 2011 12:41 pm |
|
|
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
|
|
|
blo
Joined: 11 May 2009 Posts: 22
|
|
Posted: Fri Jun 03, 2011 12:57 pm |
|
|
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
|
|
Posted: Fri Jun 03, 2011 1:25 pm |
|
|
CCS doesn't give the source code for that function. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jun 06, 2011 12:25 pm |
|
|
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 |
|
|
|