Searching \ for '[PIC] Bank Selection' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/memory.htm?key=bank
Search entire site for: 'Bank Selection'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Bank Selection'
2005\10\12@112156 by markp

flavicon
face
My question is about bank selection using the STATUS RPO/RP1 bits vs. the
BANKSEL command.  When I need to transition between banks, I simply change
the RP0/RP1 bits accordingly before and after the transition.  However, I
see many examples of code in the archives that use the BANKSEL command.  I
do not see this command in the spec sheet, well for the 16C773 & 16C715 I
use anyway.  Is it applicable to all PICs or just certain ones?  What are
the advantages of its use over the RP0/RP1 select method?

Thanks.

M Peterson

2005\10\12@115349 by Andrew

flavicon
face


On Wed, 12 Oct 2005 spam_OUTmarkpTakeThisOuTspamcannontech.com wrote:

> My question is about bank selection using the STATUS RPO/RP1 bits vs. the
> BANKSEL command.  When I need to transition between banks, I simply change
> the RP0/RP1 bits accordingly before and after the transition.  However, I
> see many examples of code in the archives that use the BANKSEL command.  I
> do not see this command in the spec sheet, well for the 16C773 & 16C715 I
> use anyway.  Is it applicable to all PICs or just certain ones?  What are
> the advantages of its use over the RP0/RP1 select method?

banksel is a feature of the assembler IIRC so it doesn't appear in the
spec sheet of the PIC. The advantage of banksel is you don't need to know
which bank the register is in for the particular PIC you are assembling
for, the assembler knows it and adds code as appropriate. The disadvantage
is that it adds code everytime, even if you had the correct bank already
selected (its hard for the assembler to know that you would have a
particular bank selected at any point once you take into account gotos,
intterupts et al so it always inserts the code). Of course some humans
have that disadvantage and probably always set the appropriate RP bits :-)

Andrew

2005\10\12@115954 by Maarten Hofman

face picon face
Rochester, 12 oktober 2005.

banksel could be considered a preprocessor command, and expands into
the appropriate bit set/reset commands so that it switches to the bank
that the register (the parameter of the banksel command) is in. The
advantage here is that you can move the register to another bank
without having to worry about changing all the commands throughout
your sourcefile. This is especially useful if you use relocatable
code/variables, and you let the assembler decide which bank is used
for your variables.

The disadvantage of the banksel command is obviously that it will
increase the number of instructions, as it will blindly set the bits.
Olin has a set of macros that work less blindly, but will need help
from the personw writing the code.

Greetings,
Maarten Hofman.

2005\10\12@120914 by Bill Freeman

flavicon
face
markp@cannontech.com writes:
> My question is about bank selection using the STATUS RPO/RP1 bits vs. the
> BANKSEL command.  When I need to transition between banks, I simply change
> the RP0/RP1 bits accordingly before and after the transition.  However, I
> see many examples of code in the archives that use the BANKSEL command.  I
> do not see this command in the spec sheet, well for the 16C773 & 16C715 I
> use anyway.  Is it applicable to all PICs or just certain ones?  What are
> the advantages of its use over the RP0/RP1 select method?

       The primary advantage of BANKSEL is that you don't have to
keep track, when writing code, of in which bank a variable (or SPFR)
is allocated.  This can be especially useful with relocatable code
that lets the linker assign variable locations, in which case you
don't, in general, know the bank of a variable at program writing
time.

       The disadvantage is that it always generates two extra
instructions, adjusting both RP0 and RP1 (for the processors that have
those bits), whether what you actually need is two, one, or no extra
instructions.  This can significantly expand code size and slow
execution.

       If you *know* the banks of your references as well as the
current settings of the bank select bits at the time that you are
writing the code, and you're beyond the beginner stage in which you
don't want to think about banks, then set and clear the RP bits
yourself.

       If you're writing a module that will be relocatably linked
into several projects, and you don't want to fix up bank selection
each time you use it, and you can't restrict where the using project
places your variables, use BANKSEL.

(I'm sorry if my anti-BANKSEL bias comes through to strongly.)

                                                       Bill

2005\10\12@124054 by olin piclist

face picon face
markp@cannontech.com wrote:
> My question is about bank selection using the STATUS RPO/RP1 bits vs.
> the BANKSEL command.  When I need to transition between banks, I simply
> change the RP0/RP1 bits accordingly before and after the transition.
> However, I see many examples of code in the archives that use the
> BANKSEL command.  I do not see this command in the spec sheet, well for
> the 16C773 & 16C715 I use anyway.

That's because it's an assembler directive, not an opcode.

> What are the advantages of its use over the RP0/RP1
> select method?

The assembler figures out what the bank should be and then sets it.  It's
not a good idea to hard code bank numbers in your code.  Instead of saying
"go to bank 1" then access MYVAR, it's better to say "go to whatever bank is
required to access MYVAR" then access it.

Once you're a little more comfortable with the bank stuff, you should look
at my DBANKIF and related macros in STD.INS.ASPIC at
http://www.embedinc.com/pic.  These macros track the bank setting at
assembly time, which is then used to make only the minimum necessary
modifications to RP0 and RP1 when you request a new bank.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

More... (looser matching)
- Last day of these posts
- In 2005 , 2006 only
- Today
- New search...