Re: pic16f84 Bank 0 Bank 1
Hi,
The 'Banks' can be a difficult thing to understand when you are just starting.
Will try and explain clearly.
First, the ' Banks' are really just RAM memory.
You, the User can use certain parts of the RAM for your storing your values in whats generally refered to as Registers.
Similarly the Pic system itself needs to use the RAM for its own Registers.
In the Pic16F84 the RAM is split in to two distinct area, Bank0 and Bank1.
Both banks are used by the System and can be accessed by the User , but at specific locations only.
See Page 13 of the data sheet - this shows the Systems registers and the Users Registers refered to as ' general purpose '
Although the above is not too difficult it is when you start to code that the problems begin.
Whenever you write or read to either your User registers or the Systems register like PortA, you must ensure that the Bank Select Bit is set accordingly.
This is done by using special bits in the Status register.
An example would be :-
Code:
bcf STATUS, RP0 ; Select Bank 0
bcf PORTB ; clear Port B
movlw b'00000000' ; value to make PortB digital Output
bsf STATUS,RP0 ; select Bank 1
movwf TRISB ; Set TRISB to Output
bcf STATUS,RP0 ; Set to Bank 0
That example just used the system registers, for you User registers it exactly the same, but before you can use them you must tell the program the name of your Registers and thier location.
Code:
cblock 0x0C ; define users registers at location 0x0C BANK 0
userone
usertwo
etc etc
endc
movlw 0xFF ; load W with hex 0xFF
bcf STATUS,RP0 ; SET TO BANK 0 if not already in there
movwf userone ; store 0xFF in register userone