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

Memory Models

I have a small test program which continuously sends characters (ascii table) to the serial ports (ST uPSD3233). The program runs fine when the memory model is:

Memory Model: small: variables in DATA
Code ROM Size: Large: 64K program

But I get garbage when I change from "Memory Model: small: variables in DATA" to "Large: variables in XDATA".

Where should I be looking to fix the problem?

Thanks.

Parents

  • The chip has on-chip external flash which can be used as external RAM.

    This seems unlikely to me. You have to perform a little algorithm (four bus cycles long) to program a word of flash, and you have to erase it first, as you can only write bits from "1" to "0" and not vice versa without erasing. Also, flash has a limited number of times it can be erased and re-written, usually about 100k or 1M these days -- which is fine for most applications, but you'd burn the flash out pretty quickly if you stored program variables in one. A million changes isn't a lot if you're talking about "for (i = 0;; ++i)". Flash is a sort of programmable ROM, as opposed to a sort of nonvolatile RAM.

    The chip does have an 8K SRAM. That presumably can be mapped to be your xdata space. I didn't study the data sheet in detail, but there are some chip-specific configuration registers you have to set to control where the SRAM shows up. Double-check those to make sure your SRAM shows up at the address you used when building the project. You may need to add some custom startup code to make sure those configuration registers are properly set after processor reset.

Reply

  • The chip has on-chip external flash which can be used as external RAM.

    This seems unlikely to me. You have to perform a little algorithm (four bus cycles long) to program a word of flash, and you have to erase it first, as you can only write bits from "1" to "0" and not vice versa without erasing. Also, flash has a limited number of times it can be erased and re-written, usually about 100k or 1M these days -- which is fine for most applications, but you'd burn the flash out pretty quickly if you stored program variables in one. A million changes isn't a lot if you're talking about "for (i = 0;; ++i)". Flash is a sort of programmable ROM, as opposed to a sort of nonvolatile RAM.

    The chip does have an 8K SRAM. That presumably can be mapped to be your xdata space. I didn't study the data sheet in detail, but there are some chip-specific configuration registers you have to set to control where the SRAM shows up. Double-check those to make sure your SRAM shows up at the address you used when building the project. You may need to add some custom startup code to make sure those configuration registers are properly set after processor reset.

Children
  • Drew Davis:
    " there are some chip-specific configuration registers you have to set to control where the SRAM shows up."

    That's precisely the kind of thing I was thinking of when I said that the options you specify to the tools only inform them about your system - they do not generate any code necessary to configure your system!

    You must both set the necessary registers to configure the SRAM to a certain address, and specify that address in the Tool options so that they address the SRAM appropriately!

  • Thanks for all the replies. They have been really helpful especially since this is the first time I'm working on a project of this nature.

    After setting the right values for "start" and "size" options in the target dialog box for code and data I was able to get the small test program to work fine. In the BL51 Locate dialog box I simply selected the "Use memory layout from target dialog" option (I could not understand the other options in th BL51 dialog box and found nothing in the documentation so I left them vacant).

    However I get no output on the serial ports when I try to execute my real project which is much larger in size.

    Andrew Neil:
    You must both set the necessary registers to configure the SRAM to a certain address, and specify that address in the Tool options so that they address the SRAM appropriately!

    According to our hardware engineer I do not have to worry about this because after the reset the hardware comes up configured already with the SRAM mapped at the right location.

    I also looked at the map file and found the following:

    ACTIVE MEMORY CLASSES OF MODULE: FIRSTPROJ(SERIALIO)

    BASE        START       END         USED      MEMORY CLASS
    ==========================================================
    C:000000H   C:000000H   C:00FFFFH   009434H   CODE
    I:000000H   I:000000H   I:0000FFH   000001H   IDATA
    X:000000H   X:000000H   X:00FFFFH   000256H   XDATA
    I:000020H.0 I:000020H.0 I:00002FH.7 000001H.3 BIT
    I:000000H   I:000000H   I:00007FH   00000FH   DATA
    
    This seems to match fine with the values I am using.

    I don't have the ISD51 debugger so I thought I'd try to use the MON51 but it requries minimum 256K of RAM, this chip only has 8K.