Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

I have a problem

Status
Not open for further replies.

Electrical

New Member
Firstly I'm sorry for my bad English

I'm new in pics.I have been trying to make a program which lights a led which is connected to PORTB's 0.bit but everytime I run program I recieve the message:
Register in operand not in bank 0. Ensure that bank bits are correct.

this is the program:
00001 LIST P=16F84A
00002 INCLUDE "P16F84A.INC"
00001 LIST
00002 ; P16F84A.INC Standard Header File, Version 2.00 Microchip Technology, Inc.
00134 LIST
0000 1283 00003 BCF STATUS, 5
0001 0186 00004 CLRF PORTB
0002 1683 00005 BSF STATUS, 5
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0003 0186 00006 CLRF TRISB
0004 1283 00007 BCF STATUS, 5
0005 1406 00008 BSF PORTB, 0
00009 END


So, what is the problem :)
 
Refer to the datasheet under memeory organization. You will realise that the TRISB registers is in bank1, while the STATUS and PORTB registers are in bank0. You will need to switch to bank1 in order to access the TRISB register.
 
Electrical said:
I have already written BSF STATUS, 5 in program to switch to bank1.Is this command not enough to switch to bank1 ?
Oh ... sorry. I must have been dreaming. Anyway, it's just a nuisance warning. You may disable those messages by ignoring 302 messages.

ERRORLEVEL -302
 
Electrical said:
I have already written BSF STATUS, 5 in program to switch to bank1.Is this command not enough to switch to bank1 ?

Yes, that's all that's required, you're not getting an error message, simply a warning to remind you that the program requires a bank change. If you want you can turn the warnings off, see 'errorlevel' in the MPASM helpfile (or check my later tutorials, where I add the required line).

It's also advisable to switch to bank one like this:

Code:
bsf 	STATUS,	RP0

It makes it clearer, I've no idea what bit 5 might be!.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top