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

Problems with storing data in ROM & lockups

Hello, I have data structures of the following type


const void * testpanel_pointers[][4] =
{
        { "Status", NULL, NULL, NULL },
        { "Configuration", NULL, NULL, NULL },
        { "Self Test", NULL, NULL, NULL },
        { "Day", NULL, NULL, NULL},
        { "Begin Countdown", NULL, NULL, NULL },
        { "Value", (void*)&edit_test, (void*)IntEdit::getString, "C" },
        { "Refresh Menu", NULL, NULL, NULL },
        { "Submenu->", NULL, NULL, NULL },
};

that I want to be stored in ROM as opposed to RAM, which is of course much more limited in size. The values are parameters that depend on the type of object that needs to be created. In the above example, some are C-strings, some are addresses of integers, and some are function pointers. However, the compiler/linker keeps treating the above data as RW-data, which produces lock-ups after the total exceeds about 1040 bytes.

Does anyone know what might be wrong?

  • const void * const testpanel_pointers[][4] =

    ?

  • Yes, using an array of structures would definitely be better than having each entry be an array of four void pointers.

  • Thank you both for your replies.

    That second const does help significantly and going with a structure containing four const void pointers pretties it up nicely. However, a new problem has arisen:

    Version 1

    const PParams testpanel_pointers[] =
    {
            { "Status", NULL, NULL, NULL },
            { "Configuration", NULL, NULL, NULL },
            { "Self Destruct", NULL, NULL, NULL },
    -->     { "Day", DaysOfWeek[list_index_test], (void*)ListEdit::getString, "" }, <--
            { "Begin Countdown", NULL, NULL, NULL },
            { "Change me", (void*)&edit_test, (void*)IntEdit::getString, "C" },
            { "Refresh Menu", NULL, NULL, NULL },
            { "Submenu->", NULL, NULL, NULL },
    };
    

    Program Size: Code=49028 RO-data=5732 RW-data=1076 ZI-data=30804

    Version 2

    const PParams testpanel_pointers[] =
    {
            { "Status", NULL, NULL, NULL },
            { "Configuration", NULL, NULL, NULL },
            { "Self Destruct", NULL, NULL, NULL },
    -->     { "Day", NULL, NULL, NULL },               <--
            { "Begin Countdown", NULL, NULL, NULL },
            { "Change me", (void*)&edit_test, (void*)IntEdit::getString, "C" },
            { "Refresh Menu", NULL, NULL, NULL },
            { "Submenu->", NULL, NULL, NULL },
    };
    

    Program Size: Code=48960 RO-data=5780 RW-data=948 ZI-data=30804

    This is totally weird. How does replacing 3 NULL values with real values cause my RAM usage to jump by 128 bytes? Why isn't it treating this as RO-data? Not to mention the fact that the system hangs with version 1 but not version 2.

  • "How does replacing 3 NULL values with real values cause my RAM usage to jump by 128 bytes?"

    Is this the only place in your code that is referencing the DayOfWeek and the function? If so, then the compiler/linker might have previously removed the code and data associated with them when you changed these references to NULL.

  • "Is this the only place in your code that is referencing the DayOfWeek and the function? If so, then the compiler/linker might have previously removed the code and data associated with them when you changed these references to NULL."

    It is. Yeah, that sounds reasonable.

    A co-worker just helped me with the hanging issue. Since Cross-Module Optimization is turned on, I have to click Rebuild twice. After that, no more hangs. At least that's out of the way, although they could've highlighted this someplace other than an obscure part of the manual.