PDA

View Full Version : Digital Out on an A/D pin safe ?



mr.sneezy
- 20th January 2009, 23:59
To keep it short, I'm replacing a legacy PIC with a modern one (16C711 to 16F819) in a old project. I need a Digital Out on pin RA3 (no input, A or D), but the A/D config table will not allow the mix of A/D to digital I/O I used on the previous 16c711.

Sooo, if I have the ADCON1 setting to have an A/D on RA3 (and RA0 & RA1 in my case) but have TrisA set to Digital Out on RA3 will I cause any problems for the PIC while driving the pin as digital out?

I've used PIC A/D's heaps in the past but alway kept the digital functions well apart from the analogue.

Cheers,
Martin

Darrel Taylor
- 21st January 2009, 05:26
Safe? ... No.
Doable ... Yes.

You can set TRIS for a pin to output when that pin is in analog mode.
But even though you only want to use that pin for output, it's the reading of the pin that's a problem.

When a pin is in Analog mode, it always reads a Digital 0.
And anytime you write to any of the other pins on the same PORT, the CPU does a Read-Modify-Write of the whole PORT.
So it reads the output pin as 0, and writes that value back to the pin, regardless of what the original state was.

So essentially, you can use THAT Pin for digital output, but then you can't use any of the other pins on that PORT for digital output.
Digital input or analog is fine on the other pins.
<br>

mr.sneezy
- 21st January 2009, 22:48
Ah ha... That fits with what I found by experiment later on, I just thought I'd go and try it. Because I use another PortA pin to run the E line to the LCD continuously the pin in question doesn't work. I guess from what you explain it does work briefly, but only until I toggle the LCD E pin again.

Oh well, off to cut some PCB tracks....

Martin