Searching \ for '[PIC]: Experimenting with F872 -- can't read from' 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/devices.htm?key=pic
Search entire site for: 'Experimenting with F872 -- can't read from'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Experimenting with F872 -- can't read from '
2002\02\28@021730 by Pic Dude

flavicon
face
What am I doing wrong here?  I tried to configure port A as all digital
inputs, but can't read from it.  If I replace port A with port C, it works.
Here's the init/main part of my code...

    [ includes, config, etc up here ]

   movlw B'00111111'
   movwf TRISA     ; Port A is all inputs
   movlw B'00000110'
   movwf ADCON1    ; Port A is all digital
   movlw B'00000000'
   movwf ADCON0    ; Turn off A/D
   tris PORTB      ; Port B is all outputs
   tris PORTC      ; Port C is all outputs

loop:
   movf PORTA,0    ; Grab data at port A
   movwf PORTB     ; Dump to port B
   goto loop

   end

Thanks,
-Neil.

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


2002\02\28@023045 by Quentin

flavicon
face
Pic Dude wrote:
>
> What am I doing wrong here?  I tried to configure port A as all digital
> inputs, but can't read from it.  If I replace port A with port C, it works.
> Here's the init/main part of my code...
The dreaded old bank select problem. Read piclist.com and the data
sheets about register banks and bank switching.

Quentin

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


2002\02\28@023930 by Martin Buehler

flavicon
face
you have to disable the a/d converters, sharing the pins of port a. they
are enabled by default. so port a works well as digital output, but you
will always read a 0, until you disable the a/d's (took me about 2 days of
debugging a driver, that worked well on a 16f84 before...)
tino

ADCON1 = 0x06;           //set 16f872 port a to digital





Quentin <spam_OUTqscTakeThisOuTspamICON.CO.ZA>
Gesendet von: pic microcontroller discussion list <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU>
28.02.02 08:23
Bitte antworten an pic microcontroller discussion list


       An:     PICLISTspamKILLspamMITVMA.MIT.EDU
       Kopie:
       Thema:  Re: [PIC]: Experimenting with F872 -- can't read from PORTA ???


Pic Dude wrote:
>
> What am I doing wrong here?  I tried to configure port A as all digital
> inputs, but can't read from it.  If I replace port A with port C, it
works.
> Here's the init/main part of my code...
The dreaded old bank select problem. Read piclist.com and the data
sheets about register banks and bank switching.

Quentin

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

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


2002\02\28@080036 by Olin Lathrop

face picon face
>>
   movlw B'00111111'
   movwf TRISA     ; Port A is all inputs
   movlw B'00000110'
   movwf ADCON1    ; Port A is all digital
   movlw B'00000000'
   movwf ADCON0    ; Turn off A/D
   tris PORTB      ; Port B is all outputs
   tris PORTC      ; Port C is all outputs

loop:
   movf PORTA,0    ; Grab data at port A
   movwf PORTB     ; Dump to port B
   goto loop

   end
<<

For one thing, you've totally ignored bank settings.  You do need to pay
attention to these.  Check out my DBANKIF and related macros if you want a
more automatic way of setting the banks.  You can find them in STD.INS.ASPIC
at http://www.embedinc.com/pic.

Secondly, don't use the TRIS instruction.  I'm surprised the assembler
didn't give you a warning.  This is an old instruction that is (has) being
obsoleted.  Note that it's not in the list of instructions on page 136 of
DS30292C.

It looks like you may have programmed some old chips a long time ago.  It's
time to sit down and read the manual again for the chip you are using now.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, .....olinKILLspamspam.....embedinc.com, http://www.embedinc.com

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


2002\02\28@081433 by Michael Rigby-Jones

flavicon
face
{Quote hidden}

Is there even one mid-range device that dosen't support the TRIS instruction
on ports A,B and C?

Mike

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


2002\02\28@104933 by Pic Dude

flavicon
face
"Slap on the wrist accepted" -- I'll go read up on it.
Thanks.


----- Original Message -----
From: "Quentin" <@spam@qscKILLspamspamICON.CO.ZA>
To: <KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU>
Sent: Thursday, February 28, 2002 1:23 AM
Subject: Re: [PIC]: Experimenting with F872 -- can't read from PORTA ???


> Pic Dude wrote:
> >
> > What am I doing wrong here?  I tried to configure port A as all digital
> > inputs, but can't read from it.  If I replace port A with port C, it
works.
{Quote hidden}

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


2002\02\28@105707 by Pic Dude

flavicon
face
0x06 is what I have, but as B'00000110'.
But you've sorta hit on a point of confusion I had with the table explaining
the ADCON1 register (REGISTER 10-2, PAGE 82 of the datasheet).
What does the columns "Vref+" and "Vref-" mean in that table?  For
PCFG3:PCFG0 = '011x' (all digital), the table entries for Vref+ and
Vref- are "Vdd" and "Vss".  So what does that mean that I need to do?

Thanks.



{Original Message removed}

2002\02\28@110135 by Pic Dude

flavicon
face
Thanks. I'll check that out.
Yep, I'm aware of TRIS being obsolete, but I was being sloppy since
I started with some sample code that used it.  I did get warnings, but
figured I'd feel like a pro if I already had some bad habits :-)

Actually I've never programmed PICs before.  Last thing I programmed
was an 8051 over 10 years ago, but most of my assembly was on a
Z80 (TRS-80 computer) about 20 years ago.  Ack!!!!

Cheers,
-Neil.



{Original Message removed}

2002\02\28@120748 by Olin Lathrop

face picon face
> Is there even one mid-range device that dosen't support the TRIS
instruction
> on ports A,B and C?

Officially many of them don't, including the 16F872.  Some silicon, may,
this rev, support the instruction without it being listed.  You definitely
don't want to be writing TRIS in new code for these chips.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, RemoveMEolinTakeThisOuTspamembedinc.com, http://www.embedinc.com

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


2002\02\28@144831 by uter van ooijen & floortje hanneman

picon face
>> Is there even one mid-range device that dosen't support the TRIS
>> instruction on ports A,B and C?
> Officially many of them don't, including the 16F872.

Same for 873,4,6,7 (TRIS is not mentioned in the instruction set).
But it does still work in all chips I use....

Wouter van Ooijen
--
Van Ooijen Technische Informatica: http://www.voti.nl
Jal compiler, Wisp programmer, WLoader bootloader, PICs kopen

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


2002\02\28@181007 by Olin Lathrop

face picon face
> 0x06 is what I have, but as B'00000110'.
> But you've sorta hit on a point of confusion I had with the table
explaining
> the ADCON1 register (REGISTER 10-2, PAGE 82 of the datasheet).
> What does the columns "Vref+" and "Vref-" mean in that table?  For
> PCFG3:PCFG0 = '011x' (all digital), the table entries for Vref+ and
> Vref- are "Vdd" and "Vss".  So what does that mean that I need to do?

Vref+ and Vref- are optional external voltage references for the ends of the
A/D range.  Modes that don't use them use the supply and ground as
references.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, spamBeGoneolinspamBeGonespamembedinc.com, http://www.embedinc.com

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


2002\02\28@214029 by Bob Ammerman

picon face
> Pic Dude wrote:
> >
> > What am I doing wrong here?  I tried to configure port A as all digital
> > inputs, but can't read from it.  If I replace port A with port C, it
works.
> > Here's the init/main part of my code...
> The dreaded old bank select problem. Read piclist.com and the data
> sheets about register banks and bank switching.
>
> Quentin
>

More likely it is the dreaded old "PORT A initializes as analogs problem",
read the description of ADCON1 in the datasheet.

Bob Ammerman
RAm Systems

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


2002\02\28@231601 by Dwayne Reid

flavicon
face
Bank switching!  See below:

At 01:12 AM 2/28/02 -0600, Pic Dude wrote:
>What am I doing wrong here?  I tried to configure port A as all digital
>inputs, but can't read from it.  If I replace port A with port C, it works.
>Here's the init/main part of my code...
>
>      [ includes, config, etc up here ]

     bank1           ;macro to set RAM bank 1

>     movlw B'00111111'
>     movwf TRISA     ; Port A is all inputs
>     movlw B'00000110'
>     movwf ADCON1    ; Port A is all digital
>     tris PORTB      ; Port B is all outputs
>     tris PORTC      ; Port C is all outputs

     bank0           ;macro to set RAM bank 0

{Quote hidden}

Hope this helps!

dwayne


Dwayne Reid   <TakeThisOuTdwaynerEraseMEspamspam_OUTplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 18 years of Engineering Innovation (1984 - 2002)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

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


2002\02\28@235107 by Pic Dude

flavicon
face
Yep.  It was the prob.  Solved.

I must say though that I think its weird that I address ADCON0/1 as
1FH and 9FH respectively, but still have to switch banks.



{Original Message removed}


'[PIC]: Experimenting with F872 -- can't read from '
2002\03\01@010526 by Dwayne Reid
flavicon
face
At 10:57 PM 2/28/02 -0600, Pic Dude wrote:
>Yep.  It was the prob.  Solved.
>
>I must say though that I think its weird that I address ADCON0/1 as
>1FH and 9FH respectively, but still have to switch banks.

RAM banks in the 14 bit series are addressable with only 7 address
bits.  0x9F is above 0x80 so you have to switch the bank select bits to match.

dwayne


Dwayne Reid   <RemoveMEdwaynerspamTakeThisOuTplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 18 years of Engineering Innovation (1984 - 2002)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservEraseMEspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2002\03\01@013631 by Pic Dude

flavicon
face
Ahhh...(sound of enlightenment) .
Thanks.


----- Original Message -----
From: "Dwayne Reid" <EraseMEdwaynerspamPLANET.EON.NET>
To: <RemoveMEPICLISTEraseMEspamEraseMEMITVMA.MIT.EDU>
Sent: Thursday, February 28, 2002 11:02 PM
Subject: Re: [PIC]: Experimenting with F872 -- can't read from PORTA ???


> At 10:57 PM 2/28/02 -0600, Pic Dude wrote:
> >Yep.  It was the prob.  Solved.
> >
> >I must say though that I think its weird that I address ADCON0/1 as
> >1FH and 9FH respectively, but still have to switch banks.
>
> RAM banks in the 14 bit series are addressable with only 7 address
> bits.  0x9F is above 0x80 so you have to switch the bank select bits to
match.
{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspamspamspamBeGonemitvma.mit.edu with SET PICList DIGEST in the body


2002\03\01@025812 by Michael Rigby-Jones
flavicon
face
> -----Original Message-----
> From: Olin Lathrop [SMTP:RemoveMEolin_piclistKILLspamspamEMBEDINC.COM]
> Sent: Thursday, February 28, 2002 2:18 PM
> To:   PICLISTSTOPspamspamspam_OUTMITVMA.MIT.EDU
> Subject:      Re: [PIC]: Experimenting with F872 -- can't read from PORTA
> ???
>
> > Is there even one mid-range device that dosen't support the TRIS
> instruction
> > on ports A,B and C?
>
> Officially many of them don't, including the 16F872.  Some silicon, may,
> this rev, support the instruction without it being listed.  You definitely
> don't want to be writing TRIS in new code for these chips.
>
I know that TRIS and OPTION is not listed within the data sheets of nearly
all of the more modern devices, I just wondered if anyone knew of a 14bit
device that definetly does not have support for these instructions?  They
still work on a 16F84A and a 16F876 and 16F877 to my knowledge.

Mike

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservSTOPspamspamEraseMEmitvma.mit.edu with SET PICList DIGEST in the body


2002\03\01@031802 by Carlos Ojea

flavicon
face
>> Is there even one mid-range device that dosen't support the TRIS
>instruction
>> on ports A,B and C?
>
>Officially many of them don't, including the 16F872.  Some silicon, may,
>this rev, support the instruction without it being listed.  You definitely
>don't want to be writing TRIS in new code for these chips.


If you don't use TRIS, how you configure a port for input or output with
these devices?

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body


2002\03\01@032248 by Michael Rigby-Jones

flavicon
face
> -----Original Message-----
> From: Carlos Ojea [SMTP:EraseMEcarlosojeaspamEraseMELEVELTELECOM.ES]
> Sent: Friday, March 01, 2002 8:13 AM
> To:   @spam@PICLIST@spam@spamspam_OUTMITVMA.MIT.EDU
> Subject:      Re: [PIC]: Experimenting with F872 -- can't read from PORTA
> ???
>
> >> Is there even one mid-range device that dosen't support the TRIS
> >instruction
> >> on ports A,B and C?
> >
> >Officially many of them don't, including the 16F872.  Some silicon, may,
> >this rev, support the instruction without it being listed.  You
> definitely
> >don't want to be writing TRIS in new code for these chips.
>
>
> If you don't use TRIS, how you configure a port for input or output with
> these devices?
>
Same as with any 14 bit device, you set the bank registers to give you
access to Bank1, and write directly to the appropriate TRIS register
(instead of using the 'TRIS' instruction, confusing isn't it?).

Mike

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


2002\03\01@034155 by Carlos Ojea

flavicon
face
>> If you don't use TRIS, how you configure a port for input or output with
>> these devices?
>>
>Same as with any 14 bit device, you set the bank registers to give you
>access to Bank1, and write directly to the appropriate TRIS register
>(instead of using the 'TRIS' instruction, confusing isn't it?).
>
>Mike


Thank you, Mike. I am a bit curious.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservspam_OUTspammitvma.mit.edu with SET PICList DIGEST in the body


2002\03\01@084142 by Olin Lathrop

face picon face
> If you don't use TRIS, how you configure a port for input or output with
> these devices?

 MOVWF  TRISA


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, TakeThisOuTolin.....spamTakeThisOuTembedinc.com, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email TakeThisOuTlistservKILLspamspamspammitvma.mit.edu with SET PICList DIGEST in the body


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