Jump to content

Recommended Posts


currently I have a program which uses 2 dimensional arrays to store lists of menu options. These reside in RAM, because Sourceboost wont support 2D rom arrays. (I am using SB 7.30).


I now have to expand my menus and dont have the space for them in RAM - so I must re-work the code to place the data in rom.


I can get around the 2D array problem with a little work - but in checking on my options in the forum, I see that someone mentioned a "single rom page limit" on rom arrays.


Could you explain a little more please? Is this a limit "per "rom array" or on rom arrays, total?


I could do with a more detailed explanation of rom data limits in the compiler, if you have the time... also any comments on what i am trying to do and whether the method is the best approach, etc


Link to post
Share on other sites
  • 1 month later...

Depending on the pic used, you can place those data on the flash (program).

The maximum size of the table depends of course of the device you use and the free space available.

About the 2d array, you can use a simple list of data where the odd values are menu options and even values are the related parameters. Then you can read it easly...

#define DTPIC_TABLE_SIZE 8 // table size

#define DTPIC_MENU 0x3000 // start address of menu table

#pragma DATA DTPIC_MENU, \
0x01, 0x80, \
0x02, 0xF0, \
0X07, 0X03, \
0XA1, 0xFF

The example above shows a table with four menu options; 0x01, 0x02, 0x07 and 0xA1, with the corresponding parameters; 0x80, 0xF0, 0x03 and 0xFF.

With the short explanation you give i think you want to lookup some kinda table to find out the related parameter of a given menu option.




// input: menu_opt - menu option to find out

// output: return the related parameter


unsigned char Lookup_DTPIC_Table( unsigned char menu_opt )
unsigned int val;

for( unsigned int i=0; i<DTPIC_TABLE_SIZE; i+=2 ) // <<< increment 2 at a time
val = flash_read( DTPIC_TABLE_SIZE + i ) // read 2 bytes
if(( val & 0xff ) == menu_opt ) return( val >> 8 ); // menu option found

return( false ); // menu option not found

code not tested!



Link to post
Share on other sites
  • 2 weeks later...



For that kind of tables and taking into account that menus and menu options generally involve text with different lenghts,

My usual approach is to set up a single vector with all the strings in a row and a second table with the pointers to the beginning of each string.


If the strings table exceeds a ROM page limit then I split it using the menu hierarchy os some other sensible logic.





Best regards


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...