Understanding the Role of Bank Selection in PIC Microcontroller Programming

  • Thread starter Thread starter El Moriana
  • Start date Start date
  • Tags Tags
    Microcontroller
Click For Summary
When programming PIC microcontrollers, selecting the correct bank for registers like TRISA is essential, while the STATUS register can be accessed from any bank due to its unique design. The STATUS register, located in Bank 0, controls bank selection and is accessible because of the 'A' bit in the opcode, which allows operations on the access buffer. TRISA, stored in Bank 1, requires bank select bits for access, highlighting a limitation in the RAM implementation of low-end PICs. Users are encouraged to consider upgrading to the 18F series for improved RAM access through INDF/FSR registers, which simplify the banking scheme. The design choice to make STATUS universally readable reflects its importance in microcontroller operation.
El Moriana
Messages
33
Reaction score
0
Hi there. Why is it that when programming PIC microcontrollers, you are forced to select the correct bank/page for registers like TRISA, but you can always do operations on STATUS?

From the PIC that I am using (PIC16F690) STATUS is stored in Bank 0 and TRISA is stored in Bank 1.

I get it that it's STATUS that controls which bank you are using but what makes it possible to use it whenever?
 
Engineering news on Phys.org
This is because of the 'A' bit in the opcode.
Not setting this bit causes the chip to use the 'access buffer',
consisting of the low part of the first RAM page and the high part of the last RAM page (I/O registers).

Your code works because STATUS is in the high part of the I/O registers page.
Accessing TRISA ,which is in the low part of the I/O registers page, requires you to use
the bank select bits.

Hmmmm doubtful that made it clearer. It took me a while to get the hang of it.
Microchips implementation of RAM in the low-end PIC's is, how shall I put it,
suboptimal.

If you have the chance switch up to the 18F series. These have the INDF/FSR registers for indirect RAM access (so you can forget about the cumbersome banking scheme).
 
Your question may be a 'why' question... Why is STATUS readable from any bank? Because the designers thought it important enough to make it so!

'How'? That's just part of the internal connection network (probably--I don't have access to the internal details). If you're familiar with Karnaugh maps, this question is somewhat akin to asking how it's possible to address each element of a contiguous half the Karnaugh map, when, in reality, this is (usually) simpler to do than trying to address one or two elements.
 
Ok. Still a bit unclear but I get the gist of it. Thanks =)
 
Thread 'I thought it was only Amazon that sold unsafe junk'
I grabbed an under cabinet LED light today at a big box store. Nothing special. 18 inches in length and made to plug several lights together. Here is a pic of the power cord: The drawing on the box led me to believe that it would accept a standard IEC cord which surprised me. But it's a variation of it. I didn't try it, but I would assume you could plug a standard IEC cord into this and have a double male cord AKA suicide cord. And to boot, it's likely going to reverse the hot and...

Similar threads

  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
6K
Replies
8
Views
4K
  • · Replies 6 ·
Replies
6
Views
8K
Replies
6
Views
4K
Replies
4
Views
3K