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

Discussion Overview

The discussion revolves around the programming of PIC microcontrollers, specifically focusing on the necessity of selecting the correct bank or page for certain registers, such as TRISA, while being able to access the STATUS register from any bank. The scope includes technical explanations and conceptual clarifications related to microcontroller architecture and register access.

Discussion Character

  • Technical explanation, Conceptual clarification

Main Points Raised

  • One participant questions why STATUS can be accessed from any bank while TRISA requires bank selection, noting the specific architecture of the PIC16F690.
  • Another participant explains that the 'A' bit in the opcode allows access to the 'access buffer', which includes certain I/O registers, and that STATUS is located in the high part of this buffer.
  • A different viewpoint suggests that the design decision to make STATUS universally accessible was intentional, emphasizing its importance in programming.
  • One participant expresses skepticism about the clarity of the explanation provided and mentions the suboptimal nature of RAM implementation in low-end PICs, recommending the 18F series for improved functionality.

Areas of Agreement / Disagreement

Participants express varying levels of understanding and clarity regarding the access mechanisms of registers, with some points of agreement on the technical aspects but no consensus on the overall clarity of the explanations.

Contextual Notes

Some assumptions about the internal architecture of the PIC microcontrollers and the specific roles of the STATUS and TRISA registers remain unresolved, as do the implications of the 'A' bit in opcode functionality.

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 =)
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
3K
Replies
4
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
3K
  • · Replies 6 ·
Replies
6
Views
7K
Replies
8
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
8K