Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

16F84 STATUS Register

Status
Not open for further replies.

brpathirana

Newbie level 1
Joined
Dec 29, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,287
Hellow, I have some doubts regarding Microcontroller STATUS registers. If we consider the pic 16f84;

1) Why it consists of 2 nos of STATUS registers at 2 locations?

2) If it is needed to change from bank 0 to bank 1, is it possible to write the command following way?
bsf 03h,5
What will happen if we write the command in following way?
bsf 83h,5

Pl. help me.
 

1. there is only one STATUS register. The reason it seems to be in two locations is that most programs need to access it frequently regardless of which bank is currently selected. If you consider that any instructions that tests bits in the STATUS register will either execute the next instruction or jump over it, if the bank had to be switched it would be impossible to skip the instruction without landing in the bank switching code. You will see some other registers are also mapped in all banks.

2. You might get a warning from the assembler to check the bank is selected properly but it will be seen as the same operation.

Incidentally, there is a far better way of writing the code that makes it more readable. Instead of using register and bit numbers, if you include the 16F84.inc header file at the start of your program, you can use the register and bit names instead.

For example, you can write "bsf 03h,5" as "bsf STATUS,RP0" which is easier to read.

If you are using MPLAB as your assembler (free and highly recommended) you can also use the banksel directive. All you do is write banksel followed by the name of the register you are going to use next and it will generate the code to set the RP0 and RP1 bits for you. On a 16F84 it isn't complicated to set the banking bits but if you migrate to bigger PICs where registers are spread across more banks, it becomes much easier when you use banksel.

Brian.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top