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

Simulation for far memory using L51_BANK.A51

Hi,

I'm trying to get far memory simulated for the attached program.

variable.c

unsigned char far large_array0[0x10];
main.c
unsigned char far large_array0[0x10];
extern unsigned char far large_array1[0x10];

void main (void) {
  unsigned int i;

  for (i = 0; i < sizeof (large_array0); i++)  {
    large_array0[i] = (unsigned char) i;
  }
  for (i = 0; i < sizeof (large_array1); i++)  {
    large_array1[i] = (unsigned char) i+0x80;
  }
  for (i = 0; i < 20; i++)  {
    if(large_array0[i]!=i) goto error;
  }
  while (1);
error:
  while(1);
}
To make sure I have two different banks for the two arrays, I added the following line to the linker in the user classes:
HDATA (X:0x028000-X:0x028010, X:0x038000-X:0x038010) 
The link map shows indeed that the two variables are placed in different banks:
BASE        START       END         USED      MEMORY CLASS
==========================================================
X:000000H   X:000000H   X:007FFFH             XDATA
C:000000H   C:000000H   C:007FFFH   0001E9H   CODE
X:000000H   X:028000H   X:028010H   000020H   HDATA
            X:038000H   X:038010H               
I:000000H   I:000000H   I:0000FFH   000001H   IDATA
I:000000H   I:000000H   I:00007FH   000008H   DATA

      VALUE       CLASS    TYPE      PUBLIC SYMBOL NAME
      =================================================
      02028000H   HDATA    ---       large_array0
      02038000H   HDATA    ---       large_array1

When I simulate this program, large_array0 ends up with the data of large_array1 and the test fails.
I noticed that ?C?CLDXPTR, ?C?CSTXPTR (of L51_BANK.A51) was indeed executed and that the correct bank was selected.
It looks like the simulator did not switch memory to emulate the banks.
How do I configure the physical xdata memory banks into simulation memory of the uVision2 Simulator? Is there any documentation on this?

The device I selected was Dallas DS87C520.

Geert

Parents
  • Hi,

    Interesting to know is that when I switched to XBANKING.A51, the error was still the same. But when I switched also the device to Analog devices ADuC812 and setting the extended DPTR register for addressing HDATA, it simulated correctly!

    ?C?XPAGE1SFR  DATA  084H  ; SFR Address of XPAGE1 register (DPP register)     *
    
    It looks like the simulator is using the SFR now to switch the banks. Indeed selecting the wrong SFR, make the simulation fail. So to make simulation work, the device used must have some DPTR register that is simulated.
    But what with classic 8051 that uses some PORT bits to do the bank selection. Is there a way to do the bank switch when these bits are modified? I looked in the documentation of uVision, but i don't find any method that I can call to select the bank. Is there something I miss or is simulation indeed not possible?

    Geert

Reply
  • Hi,

    Interesting to know is that when I switched to XBANKING.A51, the error was still the same. But when I switched also the device to Analog devices ADuC812 and setting the extended DPTR register for addressing HDATA, it simulated correctly!

    ?C?XPAGE1SFR  DATA  084H  ; SFR Address of XPAGE1 register (DPP register)     *
    
    It looks like the simulator is using the SFR now to switch the banks. Indeed selecting the wrong SFR, make the simulation fail. So to make simulation work, the device used must have some DPTR register that is simulated.
    But what with classic 8051 that uses some PORT bits to do the bank selection. Is there a way to do the bank switch when these bits are modified? I looked in the documentation of uVision, but i don't find any method that I can call to select the bank. Is there something I miss or is simulation indeed not possible?

    Geert

Children
No data