Microchip Technologies MPASM

Message [302]

Question:

My source assembles with the following message:

Message[302] myfile.ASM 136 :
Register in operand not in bank 0. Ensure that bank bits are correct.

What am I doing wrong? This isn't an error, but it obviously means that something doesn't look right to mpasm and I am not trying to do anything unusual at all.

Answer:

Its just a warning that you need to select the correct bank since you are addressing a register over 0x7F, however, even if you have inserted the banksel command, you will still get the same warning (not an overly intellegent assembler here).

You can remove the warning message by inserting the following at the top of your file

ERRORLEVEL -302 ;remove message about using proper bank

But if you do make a mistake, the assembler will not catch it and this type of error can be very hard to debug.

Dwayne Reid of Trinity Electronics Systems Ltd Edmonton, AB, CANADA says

Not a problem - just a warning message that MPASM noticed that you were writing to a register with an address higher than 0x7F. The message is remind you to check that you have set the ram page bits correctly.

I use macros to ensure that the message is generated only if I've been careless. I'll give a couple of them here - you can extend them to all the opcodes that you may use or email me privately and I'll send the whole lot to you. [If you] set the ram page bits, then use [for example]

 movwf1 TRISB

[rather than]

 movwf TRISB

No more error message.

The reason for inverting the MSB in the following macros instead of just masking it is to make sure that I'm paying attention to what page I'm in - if I am in page 0 and use a page 1 macro, I get the warning message.

Macros follow:

rampg0 MACRO ;set RAM page 0
 bcf _RP0
 endm
rampg1 MACRO ;set RAM page 1
 bsf _RP0
 endm
rampg2 MACRO ;set RAM page 2
 error Ram Page 2 not available on this part
 endm
rampg3 MACRO ;set RAM page 3
 error Ram Page 3 not available on this part
 endm
bcf1 MACRO reg,bit ;diddle bits in RAM bank 1
 bcf (reg^0x80),bit ;invert MSB
 endm
bsf1 MACRO reg,bit ;diddle bits in RAM bank 1
 bsf (reg^0x80),bit ;invert MSB
 endm
movwf1 MACRO arg ;diddle regs in RAM bank 1
 movwf (arg^0x80) ;invert MSB
 endm
movfw1 MACRO arg ;diddle regs in RAM bank 1
 movfw (arg^0x80) ;invert MSB
 endm
swapf1 MACRO arg,d ;diddle regs in RAM bank 1
 swapf (arg^0x80),d ;invert MSB
 endm
andwf1 MACRO arg,d ;diddle regs in RAM bank 1
 andwf (arg^0x80),d ;invert MSB
 endm

Also:

Questions:

Comments:


file: /Techref/microchip/mplab/msg302.htm, 6KB, , updated: 2011年3月22日 04:29, local time: 2025年9月5日 03:57,
40.74.122.252:LOG IN

©2025 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/techref/microchip/mplab/msg302.htm"> MPASM Message[302]</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here:
if you want a response, please enter your email address:
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

Welcome to massmind.org!

Welcome to massmind.org!

.

AltStyle によって変換されたページ (->オリジナル) /