Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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?
 
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.
 
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.
 
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" ?
 
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'?.
 
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?
 
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.
 
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top