@bigtoy,
Thanks for the reply.
In this line:
vLCD_WriteStr_P( (const char*)g_strMnuConf_F_10, 0, LCD_ROW_1, TRUE );
why are you casting the first parameter? g_strMnuConf_F_10 is already defined as a const char [] so it seems the cast should not be required. Were you getting a warning or something that caused you to do the cast?
You are correct, cast is not required for first parameter. I just added it to see if it makes any difference to gcc generated code when I started getting garbage on LCD to be doubly sure about pointer being passed.
In this line:
INT8U ucHandle_Menu( const char* const* mnu_array, INT8U mnu_count )
you are ending up with a pointer to a pointer. From cdecl.org:
"declare mnu_array as pointer to const pointer to const char"
Are you sure you want this extra level of pointer redirection?
Yes, again you are correct. Its pointer to array of pointers in flash to strings stored in flash. ucHandleMenu() is called from multiple locations, each caller passing different array of strings, both strings & array of pointers to those strings are in flash...
Strings in Flash...
static const char g_strMnuConf_F_1[] = "[ ]PWD Enable?";
static const char g_strMnuConf_F_2[] = "[ ]System Type";
static const char g_strMnuConf_F_3[] = "[ ]Set Yr/Mon";
static const char g_strMnuConf_F_4[] = "[ ]Set Serial";
static const char g_strMnuConf_F_5[] = "[ ]Set M1";
static const char g_strMnuConf_F_6[] = "[ ]Set M2";
static const char g_strMnuConf_F_7[] = "[ ]Set IP-FSW";
static const char g_strMnuConf_F_8[] = "[ ]Set IP-P1";
static const char g_strMnuConf_F_9[] = "[ ]Set IP-P2";
static const char g_strMnuConf_F_10[] = "[ ]Set TCON";
static const char g_strMnuConf_F_11[] = "[ ]T Calib
Array of pointers to above strings also in flash,
static const char* const g_a_strMnuConfF_P[MENU_CONFF_STR_COUNT] = {
g_strMnuConf_F_1, g_strMnuConf_F_2 ,g_strMnuConf_F_3, g_strMnuConf_F_4, g_strMnuConf_F_5,
g_strMnuConf_F_6, g_strMnuConf_F_7, g_strMnuConf_F_8, g_strMnuConf_F_9, g_strMnuConf_F_10,
g_strMnuConf_F_11,
g_strMnuPrev
};
I can see in map file that all these strings & array are allocating to rodata.
Issue in both of above cases is, without optimizations with gcc, code works fine, but with optimizations turned on (-s), pointers being passed to vLCD_WriteStr_P() & ucHandle_Menu() are wrong & hence garbage data getting displayed on LCD. With Keil, same code works fine in every level of optimization.
Hope I am able to clarify things up.
Thanks again,
_sam_des