Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 29th December 2007, 09:17 AM   (permalink)
Experienced Member
baberjaved is on a distinguished road
Default Banks in PIC Microcontrollers

I cannot seem to understand this concept from anywhere but Can someone explain to me why do we need to select certain Banks while programming PIC mCU's... and how do I know if i have selected the correct Bank?
baberjaved is offline   Reply With Quote
Old 29th December 2007, 09:26 AM   (permalink)
Super Moderator
 
Nigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to behold
Default

Simply because different GPR's and special registers are in different banks, you 'know' you have selected the correct bank because you specifically do it - refer to the datasheet for which registers are in which bank (some are in multiple banks as well).
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 29th December 2007, 09:43 AM   (permalink)
Experienced Member
Pommie is a splendid one to beholdPommie is a splendid one to beholdPommie is a splendid one to beholdPommie is a splendid one to beholdPommie is a splendid one to beholdPommie is a splendid one to beholdPommie is a splendid one to behold
Default

Because pic instructions are only 14 bit each then only 7 bits were available to contain a ram address, this meant that the chip could only access 128 bytes of ram. To get around this limitation, Microchip added 2 more bits to the STATUS register that act as bits 8 and 9 of the ram address, this makes the addressable ram a much more usable 512 bytes. These 2 additional bits are referred to as the bank bits and you have to set and clear them in order to access the different banks of ram. Some of these ram locations contain special function registers and so this ram is referred to as SFRs and the other locations are referred to as file registers (FRs). The only way to know where a certain SFR is is by consulting the data sheet.

Mike.
Pommie is online now   Reply With Quote
Old 29th December 2007, 10:35 AM   (permalink)
Experienced Member
baberjaved is on a distinguished road
Default

Thanks Nigel & Pommie that explains it quite well
baberjaved is offline   Reply With Quote
Old 30th December 2007, 01:41 PM   (permalink)
Banned
Kyle-s4h can only hope to improve
Default

When I was starting out, I always tried to look at things in a real world example -- basically, in layman's terms. My understanding of bank switching was this;

Imagine you have 4 cupboard doors -- you store the majority of dinnerware in the first, the second has glasses, the third has dessert plates/bowls, the fourth has coffee/tea cups.

For the majority of your dinner party, you will access the first cupboard, where the majority of your dinnerware is stored. However, you are in need of glasses and have asked a guest to get them for you -- but your guest doesn't know what cupboard to go to to find glasses, unless you tell them -- if you don't they will come back and say "the glasses are not in cupboard 1" (they looked in cupboard 1 because it was the closest cupboard -- and they're not smart enough to go to the next cupboard -- unless you upgrade your guests to 18F's!). You then tell your guest that the glasses are in cupboard 2 -- they can then find them when they go to look for them.

So, if you don't tell the microcontroller where the glasses are stored, it will open the cupboard it is closest to, and if the glasses are not there, it will not be able to find them.

When you break it down to it's simplest form, it's quite easy to understand.

"Microcontroller -- I want glasses -- they are in cupboard 2 -- go get them."

"Microcontroller -- I want dessert bowls -- they are in cupboard 3 -- go get them."

"Microcontroller -- I want the SFR 'my_var' -- it is in Bank 3 -- go get it."
Kyle-s4h is offline   Reply With Quote
Old 22nd January 2008, 11:36 PM   (permalink)
Experienced Member
 
Funny NYPD has a spectacular aura about
Default

If you use some C Compilor, you don't have to worry about the bank issue.
__________________
Funny N., Au Group Electronics, USA, www.AuElectronics.com
Funny NYPD is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Quik PIC Programming kit Krumlink General Electronics Chat 5 27th January 2008 11:27 PM
Capturing and reproducing audio with a PIC Fred.Amoson Micro Controllers 14 14th December 2007 08:21 PM
Problems switchin relay with PIC Andy1845c General Electronics Chat 5 17th November 2007 06:13 PM
High ADC sampling rate PIC, 18F needed? bananasiong Micro Controllers 24 28th October 2007 12:13 PM
Four PIC with One LCD.. meera83 Micro Controllers 13 20th September 2007 06:40 AM



All times are GMT. The time now is 05:38 AM.


Electronic Circuits  |  Radio Controlled
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.