# Bank 1 and 0

Status
Not open for further replies.

#### Nick'

##### New Member
Referring to 2 different tutorials, i was taught with 2 different codes in assigning/setting the pins as an input or output.

Here is the first :
Code:
bsf STATUS,5
movlw 00h
movwf TRISA
bcf STATUS,5

Here is the second:
Code:
movlw   00h
tris    GPIO

Why the first tutorial does move the Bank to bank 1 while the second does not?

#### Pommie

##### Well-Known Member
You should use the first method unless you are on one of the 10F series. The second method is obsolete and probably won't work on future chips. It is also better is you use the assigned names,
Code:
        bsf    STATUS,[COLOR="red"]RP0[/COLOR]
movlw  00h
movwf  TRISA
bcf    STATUS,[COLOR="Red"]RP0[/COLOR]

Mike.

#### Nick'

##### New Member
What is the RP0 represents?

And i want to know why we have to increase the bank to 1.

#### Pommie

##### Well-Known Member
Have a read of lesson 1 on this page. It explains bank switching starting on page 3 but it would be useful to read all of it.

Mike.

#### Nick'

##### New Member
Thanks a lot mike, i will try to read everything in there.

While i was reading through, i saw this "xorwf GPIO, f".
Shouldn't it be "xorwf GPIO, 1" ?

#### Nigel Goodwin

##### Super Moderator
Thanks a lot mike, i will try to read everything in there.

While i was reading through, i saw this "xorwf GPIO, f".
Shouldn't it be "xorwf GPIO, 1" ?

No it shouldn't - use the correct mnemonics as provided in the include file - don't manually insert the values yourself, as it makes the code unreadable and prone to errors.

You're already using 'xorwf' and 'GPIO', so why do you not want to use 'f'?.

#### Nick'

##### New Member
What i mean here was i wanted to store the data into the GPIO and not w register. Will it automatically stored into GPIO instead of w register?

#### Pommie

##### Well-Known Member
You should use xorwf GPIO,w to store the result in the work register or xorwf GPIO,f to store it back in the file. Please don't use numbers, I don't know which is which.

Mike.

#### AllVol

##### New Member
What i mean here was i wanted to store the data into the GPIO and not w register. Will it automatically stored into GPIO instead of w register?

Nick, if you are using the 16F648, you do not need to worry about GPIO. As Pommie said, that phrase is obsolete unless you are dealing with 10 or 12 series chips from Microsoft.

I know you want to learn in a hurry, but you need to do some more reading, then ask questions of that which you do not understand.

Status
Not open for further replies.

Replies
12
Views
2K
Replies
25
Views
2K
Replies
33
Views
2K
Replies
0
Views
643
Replies
6
Views
1K