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

ZI-data too big

Hi,

I have the following BIG structure:

typedef struct
{
        BYTE c_re[3];
        int c_gnrl;
        float c_time[2];

        BYTE c_cmm[13];
        int c_cmm_p[2];

        BYTE c_ext[10];
        int c_ext_p[10];

        int c_stp[50][3];

        int m_gnrl[100][10];

        float m[100][22];

        float m_e[100][22];
        float s_clb_[10];

        int an[100][22];

}pthm;

pthm test;

void main()
{
 test.an[0][0]
}


The problem is quite obvious, its too big.
How can I make sure it doesn't consume the ZI-data memory?

kind regards,
Wim

Parents
  • ZI is nothing magic - it is just zero-initialized memory. It doesn't consume space in the program but it does consume space in the RAM. Without seeing any actual error messages, I guess that your data is larger than what fits in the memory region defined for read-write data.

    If you really do need the above data quantity, then you might have to look for another processor. Or see if the processor has support for an external memory expansion. But it is often expensive (besides the loss of port pins) with external memory chips.

Reply
  • ZI is nothing magic - it is just zero-initialized memory. It doesn't consume space in the program but it does consume space in the RAM. Without seeing any actual error messages, I guess that your data is larger than what fits in the memory region defined for read-write data.

    If you really do need the above data quantity, then you might have to look for another processor. Or see if the processor has support for an external memory expansion. But it is often expensive (besides the loss of port pins) with external memory chips.

Children
  • Hi,

    I'm using a LPC2368 and my program is not that big. So i would like to put this struct in my FLASH memory instead of my RAM which is to small.

    I think I have to make a scatter file so i tryed this:

    LR_IROM1 0x00000000 0x00080000  {    ; load region size_region
      ER_IROM1 0x00000000 0x00020000  {  ; load address = execution address
       *.o (RESET, +First)
       *(InRoot$$Sections)
       .ANY (+RO)
      }
      RW_IRAM1 0x00021000 0x00030000 {
            .ANY(+RW +ZI)
            }
    
    }
    

    I changed the adress of the RAM memory in the FLASH memory region.

    But my program crashes.

    Is it an option to make place in my FLASH memory for RW variables?

  • But Flash is essentially Read-Only - isn't it?

  • No. Only the manufacturer can rebuild the processor into replacing the flash with R/W memory (EEPROM, FRAM or similar). But such a processor will be more expensive which is the reason it doesn't have directly writeable non-volatile memory instead of the flash region in the first place.

    The flash memory in the LPC2368 is writeable, but only after erasing full sectors and only by using special monitor commands. Because of this, it does not qualify as R/W memory where the compiler can generate direct write instructions for updating variables.

    A variable needs to be in a memory region where the processor can change (vary) the value with normal write instructions.

    A constant can be placed into the code segment, since it is never modified.

    It doesn't matter if you say that your program isn't so large. Your data structure definitely is large in relation to the amount of RAM in your selected processor. You always have to define small/large based on the available resoures.

  • Look at it this way: you could, in principle, change a car into a truck - but it would be a whole lot easier to just buy a truck if that's what you need!