Searching \ for '[PIC]: PIC10 TRIS register' 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: 'PIC10 TRIS register'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: PIC10 TRIS register'
2005\01\21@064635 by Anthony Van Herrewege

picon face
Hi,

I'm having some problem with PIC10 code I'm trying to compile. Several times in the program loop pins get changed from input to output and vice versa, to do this a BCF/BSF TRISGPIO, <pin nr> command is used. As far as I know that's the correct way, since there's no TRIS instruction and in the PIC10 datasheet the TRIS register is named TRISGPIO.

However, nowhere in the P10F202.inc file there's a constant TRISGPIO defined. There isn't any line in there that's got anything to do with the TRIS register as far as I can. Also the TRISGPIO register hasn't got a physical address according to the PIC10 datasheet. So, when I compile MPASM tells me it doesn't know any TRISGPIO.

I've been searching & reading the PICList archives for 2 hours yesterday, but the only thing I can find regarding TRIS stuff is mostly people complaining about the TRIS function not being supported by MC anymore (which I don't get, as far as I see you can't use it to change 1 specific pin from input -> output without knowing the I/O status of the other pins).

So, has anybody got any idea on how I set the TRIS register for the PIC10? Is it a bug in MPLab and should I wait for a new version to come out or am I overlooking something?

Thanks, Anthony


Website: http://members.lycos.nl/anthonyvh

               
---------------------------------
Do you Yahoo!?
Yahoo! Mail - now with 250MB free storage. Learn more.

2005\01\21@070657 by David Duffy

flavicon
face
Anthony Van Herrewege wrote:

>Hi,
>
>I'm having some problem with PIC10 code I'm trying to compile. Several times in the program loop pins get changed from input to output and vice versa, to do this a BCF/BSF TRISGPIO, <pin nr> command is used. As far as I know that's the correct way, since there's no TRIS instruction and in the PIC10 datasheet the TRIS register is named TRISGPIO.
>
>However, nowhere in the P10F202.inc file there's a constant TRISGPIO defined. There isn't any line in there that's got anything to do with the TRIS register as far as I can. Also the TRISGPIO register hasn't got a physical address according to the PIC10 datasheet. So, when I compile MPASM tells me it doesn't know any TRISGPIO.
>
>I've been searching & reading the PICList archives for 2 hours yesterday, but the only thing I can find regarding TRIS stuff is mostly people complaining about the TRIS function not being supported by MC anymore (which I don't get, as far as I see you can't use it to change 1 specific pin from input -> output without knowing the I/O status of the other pins).
>
>So, has anybody got any idea on how I set the TRIS register for the PIC10? Is it a bug in MPLab and should I wait for a new version to come out or am I overlooking something?
>

The datasheet spells it all out. Look at the source code for AN958 to
see it implemented. It's different to the usual PIC way of doing things!
Hint: The TRIS is only writable and uses a special instruction to load it.
You can't BSF/BCF it directly. AN958 will explain it all clearly. :-)
www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en021266
David...

2005\01\21@082052 by Anthony Van Herrewege

picon face
Hi David,

Thanks a lot for pointing me to that code. I understand now, although it's pretty stupid if you ask me. If MC says don't use the TRIS instruction, then why do they force you to use them on their newest PICs?

Also, why do they give the TRIS register the name TRISGPIO? You can't write to it or read it...

Thanks, Anthony

David Duffy <spam_OUTdavidTakeThisOuTspamaudiovisualdevices.com.au> wrote:
Anthony Van Herrewege wrote:

The datasheet spells it all out. Look at the source code for AN958 to
see it implemented. It's different to the usual PIC way of doing things!
Hint: The TRIS is only writable and uses a special instruction to load it.
You can't BSF/BCF it directly. AN958 will explain it all clearly. :-)
www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en021266
David...

Website: http://members.lycos.nl/anthonyvh

               
---------------------------------
Do you Yahoo!?
Yahoo! Search presents - Jib Jab's 'Second Term'

2005\01\21@140715 by Andrew Warren

flavicon
face
Anthony Van Herrewege <.....piclistKILLspamspam@spam@mit.edu> wrote:

> it's pretty stupid if you ask me. If MC says don't use the TRIS
> instruction, then why do they force you to use them on their
> newest PICs?
>
> Also, why do they give the TRIS register the name TRISGPIO? You
> can't write to it or read it.

Anthony:  

It isn't "pretty stupid" if you have some historical context...  

Microchip doesn't actually say "don't use the TRIS instruction"; what
they say is "don't use the TRIS instruction on parts with directly-
accessible TRISx registers".  

If you've only recently started using PICs, you wouldn't know this...
But when there were only 12-bit PICs (16C5x), the only way of setting
the I/O data direction was with the TRIS instruction, which wrote to
an internal register that wasn't accessible through any other
firmware instructions.  

I haven't looked at the PIC10 datasheet, but I assume that it uses
the old 12-bit core.  

By the way... The TRIS instruction is perfectly safe to use on any
PIC whose instruction set contains it (and it's really preferable
whenever speed is an issue or when you want to avoid bank-switching
for some reason).  The only caveat is that it only works on ports at
addresses 4, 5, and 6 (PORTA, PORTB, and PORTC on most PICs).  

-Andy  

=== Andrew Warren -- aiwspamKILLspamcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

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