Why the need for all these banks?

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
28,702
I have used the 12 & 16 pic in the past and (thought) I understood the bank switching for 0 and 1, but now using the 12f1822 for the first time, it has 8 banks with many identical registers in each bank.
Why the need for 8 STATUS, WREG et-al registers of each?
Max.
 

NorthGuy

Joined Jun 28, 2014
611
This is only one STATUS and one WREG. However, no matter what bank you select you still can access STATUS and WREG, so they appear to be present in every bank.
 

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
28,702
Thanks, so what I believe you are saying, the contents of the register is the same regardless of bank selected?
I guess the title should have been why the need for the duplicate registers!
Max.
 

jpanhalt

Joined Jan 18, 2008
11,087
As I recall, you have been using a 12F18xx. It has 31 banks. It has a core group of registers that are accessible from any bank, such as this:
upload_2016-10-29_17-32-20.png

That limitation is imposed by the 14-bit core.

The frustrating part (minor frustration) is the need to switch from Bank 0 (PORTx) to Bank 2(Latx) for the reading and writing, respectively, the ports. Of course, you can also go to 32 MHz, which limits that frustration to 125 ns, or you can cheat and just write to the port ignoring RMW.

John
 

OBW0549

Joined Mar 2, 2015
3,566
My next move (Winter's goal) is to move to the 24F series with Assembly.
If you're planning on working with any of the 16-bit PICs in assembly language, be prepared for a pleasant surprise: whether the PIC24 or the dsPIC30/33, these things are a LOT easier to work with than the 8-bit PICs. There's a fairly hefty learning curve in making the transition, but it's worth the effort.
 

OBW0549

Joined Mar 2, 2015
3,566
Thanks for the PIC24F encouragement. I will probably start with the 24F16KA102 as that is fully supported by MPLab 8.92.
The dsPICs (30F, 33F, & 33EP) are worth considering too, IMO; even if you're not doing DSP stuff, I've found the DSP engine sometimes comes in handy for math operations.

One fly in the ointment, though: while Microchip has always been supportive of assembly language programming for its 8-bit PICs, they are anything BUT supportive of anyone who wants to work with their 16-bit devices in assembler; they seem to think anyone who would want to do so must be crazy. Code examples in assembler are few and far between, except for little code snippets scattered here and there in data sheets and family reference manuals, mostly having to do with initializing and using various chip peripherals. Other than for the dsPIC30F6010 and dsPIC30F6014, there are no assembly code templates available (although those two can be modified to work with other 16-bit PICs without much trouble).

On the positive side, the C30 and XC16 floating-point libraries are free for use with assembler (see here), though it takes a bit of digging to find the info on how to call the various functions. The libraries don't take up a lot of code space, and they're very handy.
 
Top