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

Exact match. Not showing close matches.
PICList Thread
'[PIC] TRIS Problem'
2005\04\01@020607 by Chetan Bhargava

picon face
Hi All,

I'm running into a trivial problem. When I access registers from
bank1, I get the errors below, even if I switch the banks. I have
taken this piece of code from PIC16F684 datasheet. Any pointers?

I have recently upgraded my MPLAB to 7.10.the MPASMWIN version is 4.00.

Here is a snippet from the list file
<SNIP>
0005   1683           00014     BSF STATUS,RP0      ;Bank 1
Message[302]: Register in operand not in bank 0.  Ensure that bank
bits are correct.
0006   0191           00015     CLRF ANSEL      ;digital I/O
0007   300C           00016     MOVLW 0Ch       ;Set RC<3:2> as inputs
Message[302]: Register in operand not in bank 0.  Ensure that bank
bits are correct.
<SNIP>

+++++++++++++++++++++++++++++++++++++

;test program
list p=16F684
include "P16F684.inc"
org 0x00
goto main
main:
test:
BCF STATUS,RP0 ;Bank 0
CLRF PORTC ;Init PORTC
MOVLW 07h ;Set RC<4,1:0> to
MOVWF CMCON0 ;digital I/O
BSF STATUS,RP0 ;Bank 1
CLRF ANSEL ;digital I/O
MOVLW 0Ch ;Set RC<3:2> as inputs
MOVWF TRISC ;and set RC<5:4,1:0>
;as outputs
BCF STATUS,RP0 ;Bank 0
end
+++++++++++++++++++++++++++++++++++++

Thanks,

--
Chetan Bhargava
Web: http://www.bhargavaz.net
Blog: http://microz.blogspot.com

2005\04\01@021618 by David Duffy

flavicon
face
Chetan Bhargava wrote:

>Hi All,
>
>I'm running into a trivial problem. When I access registers from
>bank1, I get the errors below, even if I switch the banks. I have
>taken this piece of code from PIC16F684 datasheet. Any pointers?
>  
>

It's a warning, not an error message. MPLAB is just
reminding you to ensure you've set the bank bits.
David...

--
___________________________________________
David Duffy        Audio Visual Devices P/L
U8, 9-11 Trade St, Cleveland 4163 Australia
Ph: +61 7 38210362      Fax: +61 7 38210281
Our Web Site: http://www.audiovisualdevices.com.au
___________________________________________

2005\04\01@022529 by Nicolas

picon face
>From the help:

302 Register in operand not in bank 0. Ensure that bank bits are correct.
This is a commonly seen reminder message to tell you that a variable
that is being accessed in not in bank 0. This message was added to
remind you to check your code, particularly code in banks other than
0. Review the section on banksel (banksel - Generate Bank Selecting
Code) and bankisel (bankisel - Generate Indirect Bank Selecting Code
(PIC12/16 MCUs)) and ensure that your code uses bank bits whenever
changing from ANY bank to ANY other bank (including bank 0).

Since the assembler or linker can't tell which path your code will
take, you will always get this message for any variable not in bank 0.
You can use the errorlevel command to turn this and other messages on
and off, but be careful as you may not spot a banking problem with
this message turned off. For more about errorlevel, see errorlevel -
Set Message Level.

A similar message is 306 for paging.

On Apr 1, 2005 9:06 AM, Chetan Bhargava <spam_OUTcbhargavaTakeThisOuTspamgmail.com> wrote:
{Quote hidden}

> -

2005\04\01@023242 by Hulatt, Jon

picon face
It's not an error, it's a warning- just to let you know that you need to
bank switch. Don't worry about it. You can disable it with a #pragma .

Jon

> {Original Message removed}

2005\04\01@031706 by michael brown

picon face
From: "Hulatt, Jon"


> It's not an error, it's a warning- just to let you know that you need
to
> bank switch. Don't worry about it. You can disable it with a #pragma .

You can, but I prefer doing this instead:

         bsf         STATUS, RP0         ;Switch to Bank 1
         movlw       b'00111011'         ;Define I/O on Port A
         movwf       TRISA & 0x7F
         movlw       b'00000101'         ;Define I/O on Port B
         movwf       TRISB & 0x7F
         bcf          STATUS, RP0        ;Switch to Bank 0

By ANDing the value with 0x7F, you get rid of the warning message
without completely disabling it.  This is useful when porting code to a
new chip.  If an SFR moves from BANK0 to BANK1 then you easily spot the
warning messages now showing up.  Unfortunately I don't have a clever
trick to detect an SFR that moves from BANK1 to BANK0.  It has also
saved me a fair amount of grief when writing new code.

2005\04\01@032841 by Michael Rigby-Jones

picon face


{Quote hidden}

A better way, (and I have completely forgotten the originator, maybe
Scott Dattalo or Andy Warren?) is to toggle the most significant bit
with an XOR operation e.g.

movwf        TRISB ^ 0x80

If you apply this to an SFR in Bank0 it will give you a warning, unlike
the the simple bitmask.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

2005\04\01@071322 by John J. McDonough

flavicon
face
----- Original Message -----
From: "michael brown" <.....spam-meKILLspamspam.....houston.rr.com>
Subject: Re: [PIC] TRIS Problem


> > bank switch. Don't worry about it. You can disable it with a #pragma .

I prefer to use errorlevel right at the point to remind me and not disable
the message from a point where I might shoot myself in the foot.  Also, with
SFR's moving around between processors, I much prefer to use banksel.  This
way when I rip off the code for another project I don't get a nasty
surprise.

    errorlevel -302
    banksel TRISA
    movwf  TRISA
    banksel PORTA
    errorlevel +302

I feel like this makes it a lot more obvious your intention.

--McD


2005\04\01@102651 by Bob Ammerman

picon face
>  Unfortunately I don't have a clever trick to detect an SFR that moves
> from BANK1 to BANK0.

Try this:

BANK0 = x'0'
BANK1 = x'80'
BANK2 = x'100'
BANK3 = x'180'

         bsf         STATUS, RP0         ;Switch to Bank 1
         movlw       b'00111011'         ;Define I/O on Port A
         movwf       TRISA^BANK1
         movlw       b'00000101'         ;Define I/O on Port B
         movwf       TRISB^BANK1
         bcf          STATUS, RP0        ;Switch to Bank 0


Bob Ammerman
Ram Systems





2005\04\01@114802 by Chetan Bhargava

picon face
Thank you all. Every thing was running smoothly until I upgarded my PC
and the MPLAB software :-)

Regards,

--
Chetan Bhargava
Web: http://www.bhargavaz.net
Blog: http://microz.blogspot.com

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