Helpful ReplyWhic analog channel ?

Author
DeltaElectronics
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2016/06/24 07:25:46
  • Location: 0
  • Status: offline
2017/12/05 13:13:10 (permalink)
0

Whic analog channel ?

Hello to everybody...
I am almost new of PIC programming, and now I am starting to try ANALOG Input channel.... I want to know which is the number analog channel, for evey PIN available; for example what's the analog channel no. associate to RC0 PIN, for a given MCU ?
I am asking it, because reading from datasheet is does not seem very clear.
 
#1
KTrenholm
Super Member
  • Total Posts : 274
  • Reward points : 0
  • Joined: 2012/08/08 14:04:23
  • Location: Connecticut, USA
  • Status: offline
Re: Whic analog channel ? 2017/12/05 13:15:54 (permalink)
0
In the pin function descriptions in the datasheet, you should see "AN#" with # being the analog channel of that pin.
#2
DeltaElectronics
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2016/06/24 07:25:46
  • Location: 0
  • Status: offline
Re: Whic analog channel ? 2017/12/05 13:45:12 (permalink)
0
@KTrenholm....
Yeahh, the chatch is that in the PIC16F18323 datasheet I downloaded there (http://ww1.microchip.com/downloads/en/DeviceDoc/40001799C.pdf)  is not indicated.....
For example, if you look at page 6, for RC0 its analog input channel is indicated as ANC0, instaed the library I use requires to indicate an integer value.
#3
qɥb
Monolothic Member
  • Total Posts : 171
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: Whic analog channel ? 2017/12/05 13:54:28 (permalink) ☄ Helpfulby DeltaElectronics 2017/12/07 08:22:51
+1 (1)
DeltaElectronics
... the library I use requires to indicate an integer value.

What "library" do you use?
This seems to be the critical item that you have not revealed.
At a guess, it wants the "CHS" bits documented on page 225 in "REGISTER 22-1: ADCON0: ADC CONTROL REGISTER 0"
 
 
#4
KTrenholm
Super Member
  • Total Posts : 274
  • Reward points : 0
  • Joined: 2012/08/08 14:04:23
  • Location: Connecticut, USA
  • Status: offline
Re: Whic analog channel ? 2017/12/05 13:54:44 (permalink) ☄ Helpfulby DeltaElectronics 2017/12/07 08:22:58
+1 (1)
As far as a flat channel number is concerned for that chip, the library is probably looking to set the ADCON0.CHS bits.
 
Check page 225 of the datasheet.  The channel number it's looking for is likely the number it's putting into ADCON0.CHS.
ANA0 = 0
ANA1 = 1
ANA2 = 2
...
ANC0 = 16
ANC1 = 17
 
and so on.  Of course, I'm not looking at the library so I can't say for certain.
 
 
EDIT:
lol beaten to the punch by qhb by mere seconds.  SECONDS!
post edited by KTrenholm - 2017/12/05 13:58:23
#5
DeltaElectronics
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2016/06/24 07:25:46
  • Location: 0
  • Status: offline
Re: Whic analog channel ? 2017/12/07 08:27:49 (permalink)
0
@qɥb
I am using mikroc compiler.....
@KTrenholm
Very helpful... now I will try.
Thank you very much to both, because you was really helpful
#6
DeltaElectronics
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2016/06/24 07:25:46
  • Location: 0
  • Status: offline
Re: Whic analog channel ? 2017/12/07 08:33:27 (permalink)
0
@qɥb;@KTrenholm
Just tried and it worked fine :-)
I was reading from the wrong channel.
Again thank you very much for helping me.
#7
mbrowning
Just a Member
  • Total Posts : 611
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: offline
Re: Whic analog channel ? 2017/12/07 09:15:15 (permalink)
+1 (1)
There seems to be no substitute for reading the datasheet, as much as we try.

Can't remember. I've slept since then - Mark
#8
Jump to:
© 2017 APG vNext Commercial Version 4.5