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

why ret do not return??

I have been work on the UPSD3354DV mcu, my application is large than 64k, so I use the
bank1 and bank2 as code area. now I want to use other bank(like bank3) as data area, but
when select bank3 before erase it. It do not ret from the select function.
here is my code segment
//pg_vm.A51
PUBLIC PG_VM_CALL,PG_VM_RET
;
PG XDATA 7FE0H
VM XDATA 7FE2H
PG_BFR EQU 40H
VM_BFR EQU 41H
PG_OLD EQU 42H
VM_OLD EQU 43H
;
asm_PG_VM SEGMENT CODE
RSEG asm_PG_VM
USING 1
;===============================================;
PG_VM_CALL:
PUSH ACC
PUSH DPH
PUSH DPL
MOV DPTR,#PG
MOVX A,@DPTR
MOV PG_OLD,A
MOV DPTR,#VM
MOVX A,@DPTR
MOV VM_OLD,A
MOV DPTR,#VM
MOV A,VM_BFR
MOVX @DPTR,A
MOV DPTR,#PG
MOV A,PG_BFR
MOVX @DPTR,A
POP DPL
POP DPH
POP ACC
RET
;===============================================;
PG_VM_RET:
PUSH ACC
PUSH DPH
PUSH DPL
MOV DPTR,#VM
MOV A,VM_OLD
MOVX @DPTR,A
MOV VM_BFR,A
MOV DPTR,#PG
MOV A,PG_OLD
MOVX @DPTR,A
MOV PG_BFR,A
POP DPL
POP DPH
POP ACC
RET
;===============================================;
;
END

//call pg_vm_call to select bank
unsigned char idata *pPGVM = 0x40;

pPGVM = 0x40;
*pPGVM = 0x07;
pPGVM = 0x41;
*pPGVM = 0x1F;
pg_vm_call();
erase_bank(0x8000);
pg_vm_ret();

I trace the code. It do not ret from pg_vm_call, just step into the pg_vm_ret();

why it do not ret from pg_vm_call()??

Parents
  • now I want to use other bank(like bank3) as data area,

    That cannot work. For starters, actual data (i.e. variables) can't be in ROM at all --- only constants can, at least as far as your CPU and the tools know about it. Second, and much worse, you're pulling out the carpet from under your application's feet. If you switch to another code bank, you CPU will run code from that bank immediately --- but there is no code in your bank 3, is there?

Reply
  • now I want to use other bank(like bank3) as data area,

    That cannot work. For starters, actual data (i.e. variables) can't be in ROM at all --- only constants can, at least as far as your CPU and the tools know about it. Second, and much worse, you're pulling out the carpet from under your application's feet. If you switch to another code bank, you CPU will run code from that bank immediately --- but there is no code in your bank 3, is there?

Children
No data