This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Code Banking

Hello all,
We have here with us, a atmel at89c51ed2 board.

i was trying a small code banking application.
Settings are as follows.....
?B_NBANKS EQU 8
?B_MODE EQU 4

one of the switch case is as follows...

SWITCH0 MACRO ;Switch to Mem Bank0
CLR P1.1 ;Clear P1 Bit 5
CLR P1.2 ;Clear P3 Bit 3
CLR P1.3
ENDM

there are 7 more similar switch macros, with setting and clearing different bits.

I have 4 functions in Bank1, Bank2, Bank3 and Bank4. These function just print the current bank and blink some led's.

To get the current bank, i have modified the L51_BANK.a51. I got the solution for this from one of the discussion threads.

The modifications is as below
; get the current bank in which you are running


PUBLIC get_bank
get_bank:

MOV A, ?B_CURRENTBANK
ANL A, #?B_MASK

REPT ?B_FIRSTBIT
RR A
ENDM

MOV R7, A
;pachu
;MOV R7, ?B_CURRENTBANK
;end pachu
RET

;end of get_bank function


The problem is as follows, when in main, the current bank is 2,
bank1 it prints 6,
Bank2 it prints 2
bank3 it prints 6
bank4 it prints 2

so it prints only two values, 2 and 6....am i doing something wrong. is it possible to get the correct bank number i mean like 1 2 3 and 4 for 4 banks i am using...

regards
pachu

0