Searching \ for '[PIC]: analog pins' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=analog
Search entire site for: 'analog pins'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: analog pins'
2000\10\16@183216 by Tony Nixon

flavicon
picon face
Hi all,

[A bit sheepishly this time :-)]

I though if an anlog pin was set as an output you could use it as an
output pin capable of driving whatever.

On the PORTA block diagram, I can see how reading the pin is disabled
via an AND gate, but no mention is given about driving the pin hi or lo.

I just spent a day fooling around with a new prototype PCB for the
PicPocket programmer and I could not get the I2C eeproms to work. (Of
course I blamed the PCB)


I had RA3 controlling the SCL line, and analog enabled with RA0, RA1 and
RA3 set as analog. (ADCON1 set as 04h) RA3 was set as an output, not as
an input.

This did not work. I turned off the A2D and it did work.

I've now swapped the SCL pin to RC0 and all works OK with A2D enabled.

Anyone know why?

--
Best regards

Tony

ICmicro's
http://www.picnpoke.com
spam_OUTsalesTakeThisOuTspampicnpoke.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@185528 by Bob Blick

face
flavicon
face
Hi Tony,

I've used a 16C73A in this mode. The key for me was that you can't use any
instruction that does a read-modify-write. In other words, if you write to
port a, no problem. But if you do any bit write operations ON ANY PIN of
port a, it will clear your "analog" pin. So always use a shadow register.

I was using it for the clock line of a 93LC46A and it worked reliably as
long as I did what I described.

Cheerful regards,

Bob


> I though if an anlog pin was set as an output you could use it as an
> output pin capable of driving whatever.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@185950 by Andrew Warren

flavicon
face
Tony Nixon <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU> wrote:

> I though if an anlog pin was set as an output you could use it as
> an output pin capable of driving whatever.

   That's true, Tony.

{Quote hidden}

   If a pin is configured as an Analog Input, its digital state can
   NEVER be read... Not by a "MOVF PORTA,W", not by a "BTFSS
   PORTA,3", and not by the implied reads of read-modify-write
   instructions like "XORWF PORTA".  Whenever you try to read the
   pin's digital state, you'll always see a "0".

   What you may not know is that "BSF" and "BCF" are
   read-modify-write instructions, too; they work by reading the
   entire port, setting or clearing one bit, then writing the entire
   port back.

   Check this out:

       ; ADCON1 = 0x04, TRISA = xxxx0000

       MOVLW   00001000B       ;RA3 = 1.
       MOVWF   PORTA           ;

       BSF     PORTA,2         ;Read PORTA, set bit 2, then write
                               ;it back out.  In the process, RA3
                               ;is inadvertently cleared.

   After that last line executes, RA2 will be set but RA3 will be
   CLEAR:  The BSF instruction reads a "0" in bit 3, then
   writes that "0" back out after setting bit 2.

   The only safe way to write to RA3 is via instructions which
   don't read the port first... In actual practice, this usually
   means that you do all your read-modify-write operations on a
   "shadow" register in RAM, then just copy that register to PORTA
   when needed.

   -Andy


=== Andrew Warren --- aiwspamKILLspamcypress.com
=== Cypress Semiconductor Corporation
=== Interface Products Division, S.D.
===
=== The opinions expressed above do
=== not necessarily represent those of
=== Cypress Semiconductor Corporation.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@190401 by Tony Nixon

flavicon
picon face
Bob Blick wrote:
>
> Hi Tony,
>
> I've used a 16C73A in this mode. The key for me was that you can't use any
> instruction that does a read-modify-write. In other words, if you write to
> port a, no problem. But if you do any bit write operations ON ANY PIN of
> port a, it will clear your "analog" pin. So always use a shadow register.
>
> I was using it for the clock line of a 93LC46A and it worked reliably as
> long as I did what I described.
>
> Cheerful regards,
>
> Bob

Hi Bob,

That would explain it - thanks.

Analog pins always read as '0', so '0' gets written back regardless of
the output state, and I was using BSF, BCF.

--
Best regards

Tony

mICro's
http://www.picnpoke.com
.....salesKILLspamspam.....picnpoke.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@194214 by Dan Michaels

flavicon
face
Tony Nixon wrote:
.........
>Analog pins always read as '0', so '0' gets written back regardless of
>the output state, and I was using BSF, BCF.
>

Hi Tony, I think this is not exactly correct. If you only exercise
a single pin uisng BSF/BCF, it will work correctly, but if you do
successive BSF/BCFs to > 1 PortA pins, then only the last will be
operated upon corrrectly, and all others will always end up being
cleared.

BSF PORTA, 0
BSF PORTA, 1
BSF PORTA, 2

will leave the port in the following state:  xxxx'x100

[either that or it's naptime].

cheers,
- Dan Michaels

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@194626 by ArthurBrown

flavicon
face
Hi Tony.

Just a thought I was playing about with this and it may of  help to you
its based on a summing amp circuit.

port x0 via pot to opamp input (1) summing amp. set for low voltage i.e..
3v7
port x1 via pot to opamp input (2) summing amp. set for high voltage i.e..
6v7
pot (3) to set working voltage input (3) summing amp set at 5v0

you can then get 4 voltages using 2 output pins and use an AD pin to check
voltage.
I have just started on this but I have only got it down on paper,
beats the last on I was working on it used 8 output ports to AD
converter.ect ....

Regards Art

{Original Message removed}

2000\10\16@195425 by Andrew Warren

flavicon
face
Dan Michaels <EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU> wrote:

> > Analog pins always read as '0', so '0' gets written back
> > regardless of the output state, and I was using BSF, BCF.
>
> I think this is not exactly correct.

   No, it is exactly correct.

> If you only exercise a single pin uisng BSF/BCF, it will work
> correctly....

   But it will have side-effects on any other pins within the port
   which are configured as analog inputs and digital outputs.

> .... but if you do successive BSF/BCFs to > 1 PortA pins, then only
> the last will be operated upon corrrectly, and all others will
> always end up being cleared.

   Not true.  When that happens, it's because of the circuitry
   OUTSIDE the PIC, not because of any limitation inside the PIC.

> BSF PORTA, 0
> BSF PORTA, 1
> BSF PORTA, 2
>
> will leave the port in the following state:  xxxx'x100

   Not if RA0, RA1, and RA2 are disconnected from any outside
   circuitry... Or if the PIC is running at a low clock speed.

   -Andy


=== Andrew Warren -- aiwspamspam_OUTcypress.com
=== Staff Applications Engineer
=== Interface Products Division
=== Cypress Semiconductor
===
=== for tech support:
=== @spam@usbappsKILLspamspamcypress.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@205358 by Dan Michaels

flavicon
face
Andy,

I was referring to the situation where you are attempting
to use an analog-configured pin as a digital output, which
is what I thought Tony was asking about ???????????

BTW, tell me why I can't ever get my hands on any Cypress
FIFOs. Nobody ever seems to have them. Has Cypress stopped
manufacturing them?

- danM
======================


{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@212551 by Bob Ammerman

picon face
----- Original Message -----
From: Dan Michaels <TakeThisOuToricomEraseMEspamspam_OUTUSWEST.NET>

> Hi Tony, I think this is not exactly correct. If you only exercise
> a single pin uisng BSF/BCF, it will work correctly, but if you do
> successive BSF/BCFs to > 1 PortA pins, then only the last will be
> operated upon corrrectly, and all others will always end up being
> cleared.
>
> BSF PORTA, 0
> BSF PORTA, 1
> BSF PORTA, 2
>
> will leave the port in the following state:  xxxx'x100
>
> [either that or it's naptime].
>

Dan,

Right:

Given A,0 A,1 and A,2 defined as analog and as output:

BSF PORTA,0 will SET A.0 and CLEAR A.1 and A.2
BSF PORTA,1 will SET A.1 and CLEAR A.0 and A.2
BSF PORTA,2 will SET A.2 and CLEAR A.0 and A.1

So, when you are done you will indeed end up with a zero on A.0 and A.1, but
there will have been a nice pulse of 1 in the meanwhile.

Now that gets me to thinking: Here is  a neat trick to get a 'push-pull'
output from two PORT A pins:

1: define them as analog (ADCON1)
2: TRIS them as outputs.

Now, when you BSF either of them the other will automatically be cleared.

This would have been useful in a system I built that drove a piezo
transducer directly off two PIC pins.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@220728 by Dan Michaels

flavicon
face
Bob Ammerman wrote:
{Quote hidden}

Well Bob, that's 2 of us who seem to agree on this, although
AndyW saw it differently. Hmmm, which gets me to thinking
- ie, Mchp built some damn many "gotchas" into these thingies
that piclist can support 1800 "experts" each with a totally
different set of experiences <:-))).
==================


{Quote hidden}

Guess you could always write xxxx'xx01 and xxxx'xx10, on regular
digital pins. And actually, you can drive a piezo quite well using
a single pin on a PIC. In fact, as it is, you normally have to use
a 100-1000 ohm attenuation R in series, or it will drive you right
out of the room.

- danM

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@225404 by Andrew Warren

face
flavicon
face
Bob Ammerman <PICLISTEraseMEspam.....MITVMA.MIT.EDU> wrote:

> Here is  a neat trick to get a 'push-pull' output from two PORT A
> pins:
>
> 1: define them as analog (ADCON1)
> 2: TRIS them as outputs.
>
> Now, when you BSF either of them the other will automatically be
> cleared.
>
> This would have been useful in a system I built that drove a piezo
> transducer directly off two PIC pins.

   Clever; I don't think I've ever seen that.

   Of course, if you can't configure the pins as analog inputs
   (because, for instance, the PIC you're using doesn't HAVE an A/D
   converter), you can do this:

       MOVLW   00000001B       ;RA0 = 1, RA1 = 0.
       MOVWF   PORTA           ;

       MOVLW   00000011B
       XORWF   PORTA           ;Toggle RA0 and RA1.
       XORWF   PORTA           ;Toggle the two pins again.
       XORWF   PORTA           ;And again...

   Or, if those two pins are the only ones defined as outputs on
   that port:

       MOVLW   00000001B       ;RA0 = 1, RA1 = 0.
       MOVWF   PORTA           ;

       COMF    PORTA           ;Toggle RA0 and RA1.
       COMF    PORTA           ;Again.
       COMF    PORTA           ;And again...

   -Andy


=== Andrew Warren - EraseMEfastfwdspamix.netcom.com
=== Fast Forward Engineering - San Diego, California
=== http://www.geocities.com/SiliconValley/2499

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@225415 by Andrew Warren

face
flavicon
face
Dan Michaels <RemoveMEPICLISTEraseMEspamEraseMEMITVMA.MIT.EDU> wrote:

> I was referring to the situation where you are attempting to use an
> analog-configured pin as a digital output, which is what I thought
> Tony was asking about ???????????

   Dan:

   That IS what he was asking about, but the problem with
   analog-in/digital-out pins has nothing to do with "successive"
   writes; that's an entirely different issue related to capacitance
   and the fact that I/O Writes happen at the end of an instruction
   cycle while I/O Reads happen at the beginning of the cycle.

   Tony's problem will occur even if many minutes elapse between
   writes to a port.  The problem you described will happen whether
   or not the pins are configured as analog inputs, but only under
   certain circumstances, and then only if the writes occur in very
   rapid succession.

> BTW, tell me why I can't ever get my hands on any Cypress FIFOs.
> Nobody ever seems to have them. Has Cypress stopped manufacturing
> them?

   Don't ask me, man... I just work there.

   Seriously, though, the entire semiconductor industry is feeling
   the supply-and-demand squeeze right now; nearly every vendor
   (with, perhaps, the exception of Microchip Technology) has put
   its parts on allocation, which means that customers who want
   only a small quantity of parts may have to wait a LONG time to
   get them.

   It's a cyclical phenomenon in the industry; I wish it didn't
   happen, but the reality is that a new chip fab costs over a
   billion dollars (WAY over a billion if you're doing anything
   state-of-the-art like 300-mm wafers or 0.13-micron processes),
   and a vendor will lose customers if his parts cost just pennies
   more than someone else's.

   No vendor, therefore, can afford to have any unused production
   capacity... And since you can't build half a fab, or just ten
   percent of a fab, or lease a fab -- not when everyone else is
   ALSO at full capacity, anyway -- we all do the tightrope-
   balancing thing, striving for exactly 100% utilization of our
   fabs at all times.

   Naturally, each of us occasionally falls off the tightrope.

   Cypress seems to ba able to meet its customers' demands better
   than some companies -- not to name names, but have you tried to
   buy an AVR lately? -- but I'll honestly admit that we're not
   perfect.

   All I can suggest is that you place your order early and wait it
   out.

   Sorry...

   -Andy

   P.S.  Of course, the opinions expressed in this email do not
         necessarily represent those of Cypress Semiconductor
         Corporation; as I said, I just work there.


=== Andrew Warren - RemoveMEfastfwdspam_OUTspamKILLspamix.netcom.com
=== Fast Forward Engineering - San Diego, California
=== http://www.geocities.com/SiliconValley/2499

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@230730 by Andrew Warren

face
flavicon
face
Dan Michaels <RemoveMEPICLISTTakeThisOuTspamspamMITVMA.MIT.EDU> wrote:

> > BSF PORTA,0 will SET A.0 and CLEAR A.1 and A.2
> > BSF PORTA,1 will SET A.1 and CLEAR A.0 and A.2
> > BSF PORTA,2 will SET A.2 and CLEAR A.0 and A.1
> >
> > So, when you are done you will indeed end up with a zero on A.0
> > and A.1, but there will have been a nice pulse of 1 in the
> > meanwhile.
>
> Well Bob, that's 2 of us who seem to agree on this, although
> AndyW saw it differently.

   Dan:

   No, I didn't see it any differently.  You described a certain
   sequence of events and I explained WHY that sequence occurs.

   I wasn't arguing that it DIDN'T occur; if there was any
   misunderstanding, it was over your use of the phrase "successive
   writes to an I/O port", which is the language invariably used to
   explain ANOTHER issue with PIC I/O pins.

> Hmmm, which gets me to thinking - ie, Mchp built some damn many
> "gotchas" into these thingies that piclist can support 1800
> "experts" each with a totally different set of experiences
> <:-)))

   Yeah, I guess you're right about the "different set of
   experiences" thing... I mean, I've been on the PICLIST for five
   years and I would've SWORN that there were only about 18 of us
   experts here.

   -Andy


=== Andrew Warren - EraseMEfastfwdspamspamspamBeGoneix.netcom.com
=== Fast Forward Engineering - San Diego, California
=== http://www.geocities.com/SiliconValley/2499

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@233431 by Bob Ammerman

picon face
> > Hmmm, which gets me to thinking - ie, Mchp built some damn many
> > "gotchas" into these thingies that piclist can support 1800
> > "experts" each with a totally different set of experiences
> > <:-)))
>
>     Yeah, I guess you're right about the "different set of
>     experiences" thing... I mean, I've been on the PICLIST for five
>     years and I would've SWORN that there were only about 18 of us
>     experts here.
>
>     -Andy
>

Its easy to reconcile this latest difference in perception:

There are 1800 "experts", but only 18 experts (actually probably a few more
than that).

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\16@233450 by Bob Ammerman

picon face
> >Now that gets me to thinking: Here is  a neat trick to get a 'push-pull'
> >output from two PORT A pins:
> >
> >1: define them as analog (ADCON1)
> >2: TRIS them as outputs.
> >
> >Now, when you BSF either of them the other will automatically be cleared.
> >
> >This would have been useful in a system I built that drove a piezo
> >transducer directly off two PIC pins.
> >
>
> Guess you could always write xxxx'xx01 and xxxx'xx10, on regular
> digital pins.

Sure: But here I only have to write 1 pin and the other 'magically' switches
state. Saves me at least one instruction. Gotta have some use :-)

>  And actually, you can drive a piezo quite well using
> a single pin on a PIC. In fact, as it is, you normally have to use
> a 100-1000 ohm attenuation R in series, or it will drive you right
> out of the room.

Out of the room was the whole idea.

Actually, I used this trick to get two volume levels: for key-click prompts
and warning tones I held one output fixed and toggled the other. For the
alarm output I toggled the two outputs 180 degrees out of phase with each
other.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.




2000\10\17@004501 by Dan Michaels

flavicon
face
Bob Ammerman wrote:
......
>>
>> Guess you could always write xxxx'xx01 and xxxx'xx10, on regular
>> digital pins.
>
>Sure: But here I only have to write 1 pin and the other 'magically' switches
>state. Saves me at least one instruction. Gotta have some use :-)
>


Yeah, I know what you're talking about. Just make "sure" you
comment this new whixxxbang invention, or 6 months down the road
you're gonna be looking at this and scratching your head, and
wondering who the heck was the guy what wrote that code :).

- danM

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use RemoveMElistservKILLspamspammitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\10\17@004517 by Dan Michaels

flavicon
face
Bob Ammerman wrote:
>> > Hmmm, which gets me to thinking - ie, Mchp built some damn many
>> > "gotchas" into these thingies that piclist can support 1800
>> > "experts" each with a totally different set of experiences
>> > <:-)))
>>
>>     Yeah, I guess you're right about the "different set of
>>     experiences" thing... I mean, I've been on the PICLIST for five
>>     years and I would've SWORN that there were only about 18 of us
>>     experts here.
>>
>>     -Andy
>>
>
>Its easy to reconcile this latest difference in perception:
>
>There are 1800 "experts", but only 18 experts (actually probably a few more
>than that).
>

Bob gets the "A".

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use listservSTOPspamspamspam_OUTmitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\10\17@005109 by Dan Michaels

flavicon
face
Andy Warren wrote:
>Dan Michaels <spamBeGonePICLISTSTOPspamspamEraseMEMITVMA.MIT.EDU> wrote:
>
>> I was referring to the situation where you are attempting to use an
>> analog-configured pin as a digital output, which is what I thought
>> Tony was asking about ???????????
>
>    Dan:
>
>    That IS what he was asking about, but the problem with
>    analog-in/digital-out pins has nothing to do with "successive"
>    writes; that's an entirely different issue related to capacitance
>    and the fact that I/O Writes happen at the end of an instruction
>    cycle while I/O Reads happen at the beginning of the cycle.
>


Hmmmm, as I understand it, pins configured as analog but used as
digital outputs always "read" as digital "0". Therefore, successive
BSF instructions to a sequence of pins will always clear any pins
that were previously set, regardless of what is connected to them
externally. I thought this was the whole problem Tony was talking
about. No?

This is a different situation from where the pins are configured
as digital, and where they may have caps hanging on them externally,
and where you also use a series of BSF/BCF cmds. Here, the caps will
hold the pins temporarily.

Been there, done both - been burned every which way.
[I think I'll shut-up now].

- danM

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use KILLspamlistservspamBeGonespammitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\10\17@023117 by Bob Ammerman

picon face
----- Original Message -----
From: Dan Michaels <EraseMEoricomspamEraseMEUSWEST.NET>
To: <@spam@PICLIST@spam@spamspam_OUTMITVMA.MIT.EDU>
Sent: Tuesday, October 17, 2000 12:45 AM
Subject: Re: [PIC]: analog pins


> Bob Ammerman wrote:
> ......
> >>
> >> Guess you could always write xxxx'xx01 and xxxx'xx10, on regular
> >> digital pins.
> >
> >Sure: But here I only have to write 1 pin and the other 'magically'
switches
{Quote hidden}

Funny, I almost made a remark to that effect in my posting. Apparently great
minds think alike, or else fools seldom differ.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

> --
> http://www.piclist.com#nomail Going offline? Don't AutoReply us!
> use spamBeGonelistservspamKILLspammitvma.mit.edu?body=SET%20PICList%20DIGEST
>
>
>
>

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use .....listservspam_OUTspammitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\10\17@031456 by Andrew Warren

face
flavicon
face
Dan Michaels <TakeThisOuTPICLIST.....spamTakeThisOuTMITVMA.MIT.EDU> wrote:

> Hmmmm, as I understand it, pins configured as analog but used as
> digital outputs always "read" as digital "0". Therefore,
> successive BSF instructions to a sequence of pins will always clear
> any pins that were previously set, regardless of what is connected
> to them externally. I thought this was the whole problem Tony was
> talking about. No?

   Dan:

   What you say is true, and it IS the problem that Tony was having.

   However, you wrote an earlier message saying that my explanation
   -- which was almost word-for-word identical to what you just
   wrote -- was "not exactly correct".  I guess I just don't see
   where our explanations differ, as we seem to be in violent
   agreement.

> [I think I'll shut-up now].

   Me, too.  I think the explanation's clear now, and besides, I
   have a plane to catch in the morning.

   -Andy


=== Andrew Warren - TakeThisOuTfastfwdKILLspamspamspamix.netcom.com
=== Fast Forward Engineering - San Diego, California
=== http://www.geocities.com/SiliconValley/2499

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use .....listservspamRemoveMEmitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\10\17@070448 by Alan B. Pearce

face picon face
>Now that gets me to thinking: Here is  a neat trick to get a 'push-pull'
>output from two PORT A pins:

>1: define them as analog (ADCON1)
>2: TRIS them as outputs.

>Now, when you BSF either of them the other will automatically be cleared.

>This would have been useful in a system I built that drove a piezo
>transducer directly off two PIC pins.

This also sounds like a real crazy scheme to confuse anyone trying to reverse engineer your code. It would have them going round in circles trying to work out why you are connecting a piezo sounder across analog inputs, and be looking for the interrupt routine that is listening into them.... but then why is the code doing things to the digital outputs?????

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use RemoveMElistservspamspamBeGonemitvma.mit.edu?bodyT%20PICList%20DIGEST




2000\10\17@085421 by Olin Lathrop

flavicon
face
> I had RA3 controlling the SCL line, and analog enabled with RA0, RA1 and
> RA3 set as analog. (ADCON1 set as 04h) RA3 was set as an output, not as
> an input.
>
> This did not work. I turned off the A2D and it did work.
>
> I've now swapped the SCL pin to RC0 and all works OK with A2D enabled.
>
> Anyone know why?

The A/D setting overrides the digital useage of a port on the 16 series.
You have limited selection of A/D inputs and voltage reference inputs in
ADCON1.

The real gotcha is that the A/D wakes up enabled on the earlier 16 series
parts.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, spamBeGoneolin@spam@spamspam_OUTcognivis.com, http://www.cognivis.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use TakeThisOuTlistservspamspammitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\10\17@085430 by Olin Lathrop

flavicon
face
> > I though if an anlog pin was set as an output you could use it as
> > an output pin capable of driving whatever.
>
>     That's true, Tony.

No, it's not.  Some I/O modules will control the pin regardless of the TRIS
setting, or otherwise "take over" the operation of the pin.  The A/D is a
good example of this.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, olinEraseMEspamcognivis.com, http://www.cognivis.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use RemoveMElistservEraseMEspamspam_OUTmitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\10\17@092719 by Bob Ammerman
picon face
----- Original Message -----
From: Olin Lathrop <@spam@olin_piclistRemoveMEspamEraseMECOGNIVIS.COM>
To: <EraseMEPICLISTspam@spam@MITVMA.MIT.EDU>
Sent: Tuesday, October 17, 2000 8:25 AM
Subject: Re: [PIC]: analog pins


> > > I though if an anlog pin was set as an output you could use it as
> > > an output pin capable of driving whatever.
> >
> >     That's true, Tony.
>
> No, it's not.  Some I/O modules will control the pin regardless of the
TRIS
> setting, or otherwise "take over" the operation of the pin.  The A/D is a
> good example of this.

The datasheets I've read have said that you must TRIS analogs as inputs if
you want to read the analog voltage. They say that if you TRIS the pin as an
output, the A/D can still happen, but that it will convert the pin voltage
as driven by the digital output. I stand ready to be corrected.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use @spam@listservspam_OUTspam.....mitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\10\17@120651 by Olin Lathrop

flavicon
face
> The datasheets I've read have said that you must TRIS analogs as inputs if
> you want to read the analog voltage. They say that if you TRIS the pin as
an
> output, the A/D can still happen, but that it will convert the pin voltage
> as driven by the digital output. I stand ready to be corrected.

There may be more than one A/D implementation.  I remember running into an
A/D gotcha on one of my first PIC projects, which might have been a 16C77 or
16C924.  I wasn't using analog in, so I ignored the A/D module.  What I
didn't realize was that the A/D wakes up enabled, and that it was taking
over the analog input pins.  I was trying to use some of them as digital
outputs, but I couldn't get them to do anything even though TRIS and the
port register were set correctly.  When I finally figured out to disable the
A/D module, everything worked the way I intended it.

I've also noticed that the A/D is supposed to wake up off now on newer PICs
like the 16F87x.  Perhaps these A/Ds also have slightly different operation.
I sorta remember that you can individually disable the A/D function on
select pins by using TRIS on the 17C series.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, spamBeGoneolinEraseMEspamcognivis.com, http://www.cognivis.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use listservspamBeGonespammitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\10\17@124910 by Dan Michaels

flavicon
face
>> Bob Ammerman wrote:
...........
>>
>> Yeah, I know what you're talking about. Just make "sure" you
>> comment this new whixxxbang invention, or 6 months down the road
>> you're gonna be looking at this and scratching your head, and
>> wondering who the heck was the guy what wrote that code :).
>>
>> - danM
>
>Funny, I almost made a remark to that effect in my posting. Apparently great
>minds think alike, or else fools seldom differ.
>

Or else we were both listening to the recent thread regarding
hazards of writing too-clever code and leaving it uncommented.
[ie, I know the guy who wrote this code must have been "real"
bright, cause I sure can't figure it out :)].

- danM

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use RemoveMElistserv@spam@spamspamBeGonemitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\10\17@125930 by Dan Michaels

flavicon
face
At 09:16 AM 10/17/2000 -0400, you wrote:
{Quote hidden}

The following is straight out of my 16C7x d/s. All one has to do
is figure out Mchp-engineer-speak. [it's kinda like reading "Brave
New World" sometime, or was that "1984"?]

Now, as I recall, everything worked as stated here, except for:
"Pins configured as digital inputs, will convert an analog input."
===========================


The ADCON1, TRISA, and TRISE registers control the
operation of the A/D port pins. The port pins that are
desired as analog inputs must have their corresponding
TRIS bits set (input). If the TRIS bit is cleared (output),
the digital output level (VOH or VOL) will be converted.

The A/D operation is independent of the state of the
CHS2:CHS0 bits and the TRIS bits.

Note 1: When reading the port register, all pins configured
as analog input channels will read as cleared (a low level).
Pins configured as digital inputs, will convert an analog
input. Analog levels on a digitally configured input will
not affect the conversion accuracy.

Note 2: Analog levels on any pin that is defined as a digital
input (including the AN7:AN0 pins), may cause the input buffer
to consume current that is out of the devices specification.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use .....listservSTOPspamspam@spam@mitvma.mit.edu?body=SET%20PICList%20DIGEST




2000\10\17@142233 by Andrew Warren

face
flavicon
face
Olin Lathrop <PICLISTEraseMEspam@spam@MITVMA.MIT.EDU> wrote:

> > > I though if an anlog pin was set as an output you could use
> > > it as an output pin capable of driving whatever.
> >
> > That's true, Tony.
>
> No, it's not.

   Yes, dammit, it IS.

> Some I/O modules will control the pin regardless of the TRIS
> setting, or otherwise "take over" the operation of the pin.

   That's true, too.

> The A/D is a good example of this.

   And that's verifiably false.  Read the datasheet, Olin, or
   just... oh, I don't know... actually TRY it.

   -Andy


=== Andrew Warren - RemoveMEfastfwdspamspamBeGoneix.netcom.com
=== Fast Forward Engineering - San Diego, California
=== http://www.geocities.com/SiliconValley/2499

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use spamBeGonelistservKILLspamspam@spam@mitvma.mit.edu?body=SET%20PICList%20DIGEST




More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...