Continue to Site

Welcome to

Welcome to our site! 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.

hey guy, please answer me. my question is about PIC

Not open for further replies.


Member level 3
Apr 6, 2004
Reaction score
Trophy points
Activity points

What is the meaning of Bank in PIC microcontroller.
why we should use it? and when.
I really want to know why we should make headache for ourself and dealing with banks?
I think, the Easy PIC'n book method is good that ignore working with bank.

So when and in which PIC micro, we have to work with banks?

Is there any risk when I ignore using them?

Please help me and bring me out of this situation.:?::!::?::!::?::!::idea:

Thanks in advance.



Is you programming PIC in assembler(native leanguage for PIC)?
If the answer is NO, then don't worry, Your compiler shall solve it for you.

All PIC microcontrollers have Banks of RAM and Pages of ROM/FLASH. If you is programming in assembler must have it in account.

At Bank0, in address 0x0A0 is VAR_A and
VAR_A = 0x15

At Bank_2, in adress 0x1A0 is VAR_C and
VAR_C = 0x01

at program....
movlw 0x01
addwf VAR_C,1

then VAR_A = 0x16 and VAR_C = 0x01
You must TO CHANGE to Bank_2 before.

Good luck



    Points: 2
    Helpful Answer Positive Rating
This is one of the worst aspects of the PIC architecture. It is the source of many programming errors.

In the PIC architecture, memory (or register file) addresses are 8 bit numbers. This register file space is shared between general purpose memory and special function registers. The 8 bit address means the architecture is limited to 256 bytes.

To get beyond that, the pic uses banking. The status register has 2 bits (RP0 and RP1) that are used to select a given bank. Thus, the PIC can address a total 4*256 registers.

Look at the memory section of any PIC datasheet entitled: general prupose register file. It will show you how many banks that particular PIC has. each PIC is different.

If you are writing in assembly language, you will need to make sure that correct bank is selected. You can do this by setting or clearing RP0 and RP1 appropriately. However, you can also use BANKSEL <register name>. This is preferable since you don't have to actually know what bank it is in and if you write code for more than one model of PIC, you don't have to worry if they moved it to a different bank.

As to C, you can probably get by with out understanding banking but there are a number of cases where it does matter. Foremost is if you have multiple modules that you will be linking together.

I would bet a significant percentage of PIC programs is involved with setting or clearing the RP bits.

A bank is a portion of the RAM, whose contents are addressable using 8 bits.

To understand how this came about, think about the fact that the PIC has syngle-word instructions and the instruction word is 12, 14, 16 bits...
Since the actual instruction takes up a few of those bits (5-6 bits) then there isn't much space left in the instruction word to accommodate larger RAM addresses.

Therefore, the RAM is organized in "banks" of 256 bytes. Within the bank, the individual bytes are selected by the address contained in the instruction.
Selection of the banks is accomplished by a number of bank select bits (in the STATUS reg, the number varies, depending on the amount of RAM and thus the number of banks).

Basically BANK is used to dived memory in physicall.. In PIC mcu there are 4 banks, whenever you try to access the particulary memory u should knw that which bank its located and it requires you to set or clear RP0 and RP1 bit to select differnt banks... only SFR (SPECIAL FUNCTION REGISTER) are mirrored in all banks and there are few other register at bottom , which are freqeuntly used so you dont need to change the RP0 or RP1 bits

Its a very simple concept just read the memory page of any pic MCU datasheets and you will be fine... banks are desing so in RISC architecture u can do mulitiple access at same time.. expert can fix me if I am wrong... good luck

no, SFRs are not frequently mirrored in all banks. some are some aren't. Sometimes bank 0 and 2 are mirrored and bank 1 and 3 but it's only a few. For example, 16F877 only mirrors PCL, STATUS, INTCON, PCLATH and FSR in all 4 banks. A couple are mirrored in one other bank and the rest (>50) are in only one bank.

Fiddling with RP0 and RP1 is a nightmare, especially for newbies. Tracking down an error because you are in the wrong bank is tricky. The solution is to allways banksel but that leads to code bloat. I prefer a good C compiler since it will do the right thing and hopefully minimize RPx fiddling.

Sorry comp_freak, but banking has nothing to do with RISC. It has everything to do with squeezing more memory into a limited architecture. And its a just plain goofy way to do it. See how much easier it is to write for the AVR line.

ohh ok .. well you also cleared some of my stuff.. but when I was learing SDRAM cache system.. we created bank to increase hit rate of the cache system .. but here nothing to do with that.. oh ok.. so not all SFR are mirrored copy... yeah thats why i asked expert to fix my mistake:D

Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to