Bank switching and FSR

Status
Not open for further replies.
Now I have not read all of the posts in this thread but you seem to have missed and important point about how the register banks work in "legacy" PIC16F parts.

There are two sets of bank select bits in the status register. The set you are most familiar with select the register for the direct address mode. The second set of bits are used for the indirect address mode. There is an assembler directive "BANKISEL" that is handy for setting the register bank for the INDF register.

A warning is needed here. The bank select bits for indirect address mode are present only in PIC16F parts with more than two banks of registers.

This is because the FSR is an 8-bit register so it can hold an address for any register in the range from 0x00 to 0xFF.
 
Sorry to see your place is closing its service dept Nige, another one biting the dust.

I never heard of bash script.
Dont be too worried about structs, I've only used them once in a program, and that was only to 'get used' to them, you can easily write embedded code without, switch is another I rarely use.
 
Dan is correct, it's so long since I worked in assembler that I'd forgotten that the FSR bank was separate.

Due to how it works, you can copy from bank to bank without bank switching - however, only from 0 to 1 and 2 to 3.

Mike.
 
So, I can have a variable in bank 0 and another in bank 1, set INDF to my bank 0 variable, select bank 1 and still be able to access the bank 0 value via INDF? And the same goes for banks 2 and 3?
That's what I was hoping for! (well, 1/2 what I was hoping for...)
I've seen "bankisel" - didn't understand it. Will have another look.
 
Indf repeats in all pages.
Banksel is an assembler directive (I think thats what you cal it), when the assembler comes across it it is replaced by the page number that a file register resides in, there is a define list that tells the assembler the page locations of all the file registers so it 'knows' the bank of each.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…