Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

banksel of PIC 16f877a

Status
Not open for further replies.

PA3040

Advanced Member level 3
Advanced Member level 3
Joined
Aug 1, 2011
Messages
883
Helped
43
Reputation
88
Reaction score
43
Trophy points
1,308
Visit site
Activity points
6,936
Dear All,
This is related to 16F877a MCU

As we all aware banksel directive can use to change from bank to bank

Ex
Code:
banksel   TRISB

As per above, in front of bansele we must write name of SFR which we belong to the bank.

Now in bank1

Let's we assume now I need to transfer to the bank which PORTB belong

Ex

Code:
banksel   PORTB

As we all ware PORTB register exists on two bank ( bank 0 and bank 2).

How can we confirm that above directive belongs to which bank.

Please advice
Thanks in advance
 

I think it always selects the lowest bank if it has duplicates. It doesn't really matter though, it will work anyway.
As far as I know, all banksel does is copies the most significant bits of the registers address into the bank selection bits so it would use whichever address the assembler was told that register resided at.

Brian.
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Dear betwitx thanks for the reply

from the bank1 I need access PORTB and user define register in bank 2

So I am not sure banksel PORTB whether bank0 or bank2, if it is bank2 i will be easy
Please advice
Thanks in advance
 

The assembler will look up the address of PORTB in the "16F877A.inc" file. If you look in that file it lists it as:
Code:
PORTB            EQU  H'0006'
in the table for bank 0 so that's what it will use.
There isn't a problem using PORTB at the other bank addresses if you redefine it but the easiest way to do what you want is simply to use another banksel directive for the register you defined, for example:
Code:
banksel PORTB
<do something with PORTB>
banksel MyRegister
<do something to your user defined register called 'MyRegister'>

Brian.
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top