I am programming the PIC16F877 which has 4 memory banks each bank containing various registers. Each register has its own address.
e.g PORTA Register (bank0) is 05h and TRISA register (bank1)is 85h
Q. Each time I need to refer to a register do I have to switch banks using the status register RP0,1 bits and then address the register as its bank position
TRISA EQU H'05' ;Addressed as its position not 85h as in include file
BSF STATUS,5 ;Select bank1
MOVLW b'101111' ;Perform some function on TRISA
MOVWF TRISA ;
BCF STATUS,5 ;Reselect bank1
OR can I get away with
TRISA EQU H'85' ;This is what appears in include file
MOVLW b'101111' ;Perform function on TRISA
MOVWF TRISA ;with no bank switching
The latter technique seems to me to be the best approach as the code is shorter and i can make use of the PIC include file. The problem is that I get the following message:
'302 Register in operand not in bank 0. Ensure that bank bits are correct.'