I am using a 16F628A to go through Nigel's excellent tutorials;
in particular, I am in his second tutorial.
When I compile his code into hex and program it into the chip,
it works absolutely fine... but I am having trouble understanding
the bank selection.
In Tutorial 2.1, the start of his code is the following
BTW, earlier in the .asm file, Nigel had defined
When Nigel does the BSF STATUS, RP0, how come he doesn't also do a BCF STATUS, RP1?
I'm confused as to how he knows that he is selecting bank 1... couldn't
you also be selecting bank 3 depending upon the values in the register
STATUS when the chip powers up?
Thank you.
kcn
in particular, I am in his second tutorial.
When I compile his code into hex and program it into the chip,
it works absolutely fine... but I am having trouble understanding
the bank selection.
In Tutorial 2.1, the start of his code is the following
Code:
org 0x0000 ;org sets the origin, 0x0000 for the 16F628,
;this is where the program starts running
movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)
bsf STATUS, RP0 ;select bank 1
movlw b'11110000' ;set PortA 4 inputs, 4 outputs
movwf LEDTRIS
bcf STATUS, RP0 ;select bank 0
clrf LEDPORT ;set all outputs low
Code:
LEDPORT Equ PORTA ;set constant LEDPORT = 'PORTA'
LEDTRIS Equ TRISA ;set constant for TRIS register
I'm confused as to how he knows that he is selecting bank 1... couldn't
you also be selecting bank 3 depending upon the values in the register
STATUS when the chip powers up?
Thank you.
kcn