I need to jump from bank0 to bank4

Status
Not open for further replies.

PA3040

Advanced Member level 3
Joined
Aug 1, 2011
Messages
883
Helped
43
Reputation
88
Reaction score
43
Trophy points
1,308
Activity points
6,936
Dear All,

I need to jump from memory bank0 to bank3 of my PIC MCU 16f877a
As per following method it first jump to bank 1 and then jump to bank3
Is it possible to jump directly from bank0 to bank3?
please advice

Let say now in memory bank0
BSF STATUS,5



BSF STATUS,6

Now in bank3
 
Last edited:

Hello!

Do you think other people will understand your question?
For example if I tell you "I have a memory leak when I use stdio.h, please advice",
can you solve my problem? Of course not. You have to first tell us what kind of bank
it is. Memory of what? Inside your processor? What processor? Inside an external device?
What device? And if you can give us a piece of code showing what you already did
and where it's not what you expected, it would help to get useful replies.

Dora.
 
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
From other posts PA3040 is referring to a 14-bit midrange PIC.

I did answer this elsewhere but here it is again:

movlw b'01100000' <- note that bits 5 and 6 are set
iorwf STATUS,f

The 'iorwf' (inclusive OR function) sets any bits in the destination register that are also set in the W register. So both bits 5 and 6 would be set simultaneously.
Similarly, to clear both bits at once you could use:

movlw b'10011111' <- note that bits 5 and 6 are not set
andwf STATUS,f

The 'andwf' (logical AND function) resets any bits that are not set in the W register.

The ',f' at the end of the instruction means put the result back in the register, if you ended with ',w' the result would have been left in the W register and STATUS bits would not have been changed.

Brian.
 
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Hi,

If you now understand the bank select bits RP0 and RP1, you will find using them in your code very time consuming.

Much easier to use the ' banksel' directive I metioned before - example below.

Code:
	movlw	0xF0
	banksel TRISB		; select bank1 
	movwf	TRISB

	banksel PORTB		; select bank0, or use -
	banksel 0          	; alternative easy way to return to bank 0
	movlw	0x0F
	movwf	PORTB
 
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
I 100% agree. "banksel" and "pagesel" are the way to go. The assembler looks at the address of the register following the instruction and sets the RP0/1 bits for you. If you look at the assembly listing you will see it automatically inserts bsf and bcf instructions for the bank selecting.

Brian.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…