Understanding the Role of Bank Selection in PIC Microcontroller Programming

  • Thread starter Thread starter El Moriana
  • Start date Start date
  • Tags Tags
    Microcontroller
AI Thread 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 =)
 
Hi all I have some confusion about piezoelectrical sensors combination. If i have three acoustic piezoelectrical sensors (with same receive sensitivity in dB ref V/1uPa) placed at specific distance, these sensors receive acoustic signal from a sound source placed at far field distance (Plane Wave) and from broadside. I receive output of these sensors through individual preamplifiers, add them through hardware like summer circuit adder or in software after digitization and in this way got an...
I have recently moved into a new (rather ancient) house and had a few trips of my Residual Current breaker. I dug out my old Socket tester which tell me the three pins are correct. But then the Red warning light tells me my socket(s) fail the loop test. I never had this before but my last house had an overhead supply with no Earth from the company. The tester said "get this checked" and the man said the (high but not ridiculous) earth resistance was acceptable. I stuck a new copper earth...
I am not an electrical engineering student, but a lowly apprentice electrician. I learn both on the job and also take classes for my apprenticeship. I recently wired my first transformer and I understand that the neutral and ground are bonded together in the transformer or in the service. What I don't understand is, if the neutral is a current carrying conductor, which is then bonded to the ground conductor, why does current only flow back to its source and not on the ground path...
Back
Top