I'm quite new to the world of PICs, and I've got a couple of (hopefully
simple) questions about the PIC16C71...
1. When a pin is configured as an analog input, can it still be used as
a digital output? Or would you first have to reconfigure it as
digital I/O? The reason why I ask, is that it appears that RA1
can set up as digital I/O only if RA0 is also.
2. If you write a digital 1 or 0 to a pin which is configured as an
analog input (and has a voltage connected to it), will it damage the
PIC? Or will the digital output just be ignored by the PIC?
3. The databook states that an analog input reads as a digital 0. Does
this mean it's not a good idea to do a BSF/BCF on PORT_A if you've
got one or more pins set up as analog inputs? I guess this kind of
ties into question #2, since (I think) it would cause 0's to be
output on all analog inputs.
4. Let's say I've got RA0 & RA1 set up as analog inputs, and RA2-RA4 as
digital I/O. What happens if I write to one of the digital outputs
on PORT_A while an A/D conversion is taking place? Will it cause an
incorrect value to be converted?
I hope these questions make some sense. Any responses will be greatly
appreciated.
Thanks,
--
- Richard Friesen Little Timmy took a drink,
(spam_OUTRichard_FriesenTakeThisOuTmindlink.bc.ca) But now he'll drink no more,
For what he thought was H2O
Was H2SO4
------------------------------------------------------------------------------
--
>
> I'm quite new to the world of PICs, and I've got a couple of (hopefully
> simple) questions about the PIC16C71...
>
>
> 1. When a pin is configured as an analog input, can it still be used as
> a digital output?
No.
> 2. If you write a digital 1 or 0 to a pin which is configured as an
> analog input (and has a voltage connected to it), will it damage the
> PIC?
Since the digital output is disabled: No.
> 3. The databook states that an analog input reads as a digital 0. Does
> this mean it's not a good idea to do a BSF/BCF on PORT_A if you've
> got one or more pins set up as analog inputs?
No problem.
> 4. Let's say I've got RA0 & RA1 set up as analog inputs, and RA2-RA4 as
> digital I/O. What happens if I write to one of the digital outputs
> on PORT_A while an A/D conversion is taking place? Will it cause an
> incorrect value to be converted?
No promise, but I don't see any reason why it should. If you want
your conversion to be as good as possible Microchip recomends
executing a "sleep" directly after the conversion is started. The end
of conversion interrupt will wake the PIC up. This however gives you
problem with defining the sampling rate (since the conversion then
has to be internally RC-timed) which is crucial for calculating the
anti-aliasing filter you need.
I'm quite new to the world of PICs, and I've got a couple of (hopefully
simple) questions about the PIC16C71...
1. When a pin is configured as an analog input, can it still be used as
a digital output? Or would you first have to reconfigure it as
digital I/O? The reason why I ask, is that it appears that RA1
can set up as digital I/O only if RA0 is also.
2. If you write a digital 1 or 0 to a pin which is configured as an
analog input (and has a voltage connected to it), will it cause
excessive current and damage the PIC? Or will the digital output
just be ignored by the PIC?
3. The databook states that an analog input reads as a digital 0. Does
this mean it's not a good idea to do a BSF/BCF on PORT_A if you've
got one or more pins set up as analog inputs? I guess this kind of
ties into question #2, since (I think) it would cause 0's to be
output on all analog inputs.
4. Let's say I've got RA0 & RA1 set up as analog inputs, and RA2-RA4 as
digital I/O. What happens if I write to one of the digital outputs
on PORT_A while an A/D conversion is taking place? Will it cause an
incorrect value to be converted?
I hope these questions make some sense. Any responses will be greatly
appreciated.
Thanks,
--
- Richard Friesen Little Timmy took a drink,
(Richard_FriesenKILLspammindlink.bc.ca) But now he'll drink no more,
For what he thought was H2O
Was H2SO4
------------------------------------------------------------------------------
--
> 1. When a pin is configured as an analog input, can it still be used as
> a digital output? Or would you first have to reconfigure it as
> digital I/O? The reason why I ask, is that it appears that RA1
> can set up as digital I/O only if RA0 is also.
The manual claims not, but I think the original mask revision doesn't actually
work correctly. In several of my applications I've found that I have to set
the TRIS bits to configure the pin as a digital input. Otherwise the output
driver is enabled and fight my analog input. This completely contradicts the
description and the logic diagram in the data sheet.
> 2. If you write a digital 1 or 0 to a pin which is configured as an
> analog input (and has a voltage connected to it), will it damage the
> PIC? Or will the digital output just be ignored by the PIC?
I didn't get damage, although it might be possible. Just set the corresponding
bit in the TRIS register to a 1 to make the pin a digital input. Note that
even when you do this you can't actually _use_ it as a digital input if it
is configured as an analog input.
> 3. The databook states that an analog input reads as a digital 0. Does
> this mean it's not a good idea to do a BSF/BCF on PORT_A if you've
> got one or more pins set up as analog inputs? I guess this kind of
> ties into question #2, since (I think) it would cause 0's to be
> output on all analog inputs.
It's find to do a BSF or BCF on port A if the TRIS bits are set appropriately.
Just remember the usual caveats for using BSF & BCF on ports: the instruction
will read the logic levels at the pin (NOT the output register), and perform
the logic operation on those, and write the result to the output register.
This means that if you have a pin the PIC is trying to drive high, but external
loading is keeping it low, and you execute a BSF to set some other bit on the
port, the PIC will start trying to drive the first pin low.
> 4. Let's say I've got RA0 & RA1 set up as analog inputs, and RA2-RA4 as
> digital I/O. What happens if I write to one of the digital outputs
> on PORT_A while an A/D conversion is taking place? Will it cause an
> incorrect value to be converted?
Shouldn't affect it much, other than perhaps a tiny amount of noise (assuming
you have good grounding, etc.).