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.

New to MCUs - Can't switch between bank0 and bank1 :-(

Status
Not open for further replies.

chrisdagger

New Member
Hello,

I'm hoping someone can help me here... I'm working on a project using the PIC16HV785, and seem to be struggling to get the device to recognise inputs. When I build the .ASM, I get an warning when the build gets to the following line:
MOVLW B'00011111'
MOVWF TRISA

saying that the "register in Operand not in Bank0". Which I know. The register is in Bank1, which I have tried to switch to in the configuration section (below). Where might I be going wrong? bit 5 set and clear on the STATUS register is for the bank, correct? I've spent days on this now!

Thanks,
Chris

;CONFIGURATION SECTION

START BSF STATUS,5
MOVLW B'00011111'
MOVWF TRISA
MOVLW B'00000000'
MOVWF TRISB
MOVLW B'00000111'
MOVWF OPTION_R
BCF STATUS,5
CLRF PORTA
CLRF PORTB
 
A warning is, literally, a warning. It can also simply be a reminder, albeit a nagging one.

The million dollar question is, does your ASM file build successfully despite of the warning?
 
As eblc pointed out it is just an annoying warning and can be gotten rid of in two different ways.

1. Add the following line to the top of your code,
Code:
	errorlevel -302

Or, my preferred method, place & 0x7f on the effected lines,
Code:
START		bsf	STATUS,5
		movlw	B'00011111'
		movwf	TRISA [COLOR="Red"]& 0x7f[/COLOR]
		movlw	B'00000000'
		movwf	TRISB [COLOR="red"]& 0x7f[/COLOR]
		movlw	B'00000111'
		movwf	OPTION_R [COLOR="red"]& 0x7f[/COLOR]
		bcf	STATUS,5
		clrf	PORTA
		clrf	PORTB
I prefer this method as when the assembler nags you, you can check the bank switch is there before changing it.

Mike.
 
Last edited:
Indeed, it does build sucessfully, and without the warnings following that code. I will have to continue to do futher investigation into why the LED illuminates without a button press / logic change on the input pin...

Thanks for the advice folks... I am confident that I can take another avenue of investigation from here :)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top