Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

18F2420 Analogue Channel Selection Query

Status
Not open for further replies.
Hi all,

Sorry if this is a dumb question but if I wish to use AN12 (RB0) and I set ADCON1 (PCFG3:pCFG0) = 0010 as shown below this doesn't preclude me from using the other pins which will be set as analogue channels as digital i/o?

**broken link removed**

Thanks in advance for any help.
 
My guess is no. If you only want one channel you must use AN0, but of course I could be wrong (in fact I usually am!) :-(
 
Pins that are configured as analogue work fine as digital outputs but always read zero when read. This can cause huge problems with RMW type instructions.

Mike.
 
There - I told you so - wrong again !!!
 
You can use it it just not easy Is that not right Mike ?
You just cant do a (bcf or a bsf) but can set it High with portB or latb = b'11111110'
Or am I crazy Lol
This from the datasheet
On a Power-on Reset, RB4:RB0 are
configured as analog inputs by default and
read as ‘0’; RB7:RB5 are configured as
digital inputs.
By programming the Configuration bit,
PBADEN, RB4:RB0 will alternatively be
configured as digital inputs on POR.
 
bcf or bsf should be fine, since you don't care what RMW does with the remaining bits (it will read them as 0 and "write" them as 0).

It's RMW instructions like incf, decf, incfsz etc. that you'd have the real issues with.

Is there a particular reason you're using an12 instead of an0 for your analog input? You already laid out a PCB?

Unless you need to use the remaining pins as digital inputs, you should be able to use an12 by itself.
 
Last edited:
bcf or bsf should be fine, since you don't care what RMW does with the remaining bits (it will read them as 0 and "write" them as 0).

It's RMW instructions like incf, decf, incfsz etc. that you'd have the real issues with.

Is there a particular reason you're using an12 instead of an0 for your analog input? You already laid out a PCB?

Unless you need to use the remaining pins as digital inputs, you should be able to use an12 by itself.

I want 7 dedicated pins on a port for a RTCC. I can modify my cct so that my RTC is on portC, my lcd on portB thus I can put my analogue input back on RA0 where it was before I connected the RTC chip.

Thanks.
 

Attachments

  • port.jpg
    port.jpg
    388.9 KB · Views: 218
Rtc

Angry Badger,

Why don't you save yourself a lot of pins and use something like a PCF8535 on I2C?
Just a thought :rolleyes:
 
Angry Badger,

Why don't you save yourself a lot of pins and use something like a PCF8535 on I2C?
Just a thought :rolleyes:

gaspode42,

I'd not heard of a PCF8535 until you mentioned it. Just looked at the pdf. It looks a bit complicated for my level of understanding and I haven't dabbled with I2C yet. Something for the future.

Thanks for the advice though. Thanks Bert, kpatz, pommie.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top