In the following example, TestStr and TestInt get initialized as expected. GlobalFlashTestStr and GlobalFlashTestInt do not get initialized but show allocated space in the map and debugger. What am I missing? How do I init data in the global flash space? Thanks.
Simplified code example://----------------------------------------------------------const char TestStr[] = "Test String";const int TestInt = 1234;#pragma DATA_SEG __GPAGE_SEG USRPGM_FLASHconst char GlobalFlashTestStr[] = "Global Flash Test String";const int GlobalFlashTestInt = 5678;#pragma DATA_SEG DEFAULTvoid main(void) { for(;;) {}}//----------------------------------------------------------From PRM:SEGMENTS...FLASH_G1 = READ_WRITE 0x780000'G TO 0x78FFFF'G; // PAGE_E0 TO PAGE_E3...ENDPLACEMENT...USRPGM_FLASH INTO FLASH_G1;...ENDENTRIESGlobalFlashTestStrGlobalFlashTestIntTestStrTestIntEND//----------------------------------------------------------
Solved! Go to Solution.
Just noted that the original post contains #pragma DATA_SEG, that should be #pragma CONST_SEG instead as the objects to be placed into the globally addressed flash are constants. So it should look like this: #pragma CONST_SEG __GPAGE_SEG USRPGM_FLASH const char GlobalFlashTestStr[] = "Global Flash Test String"; const int GlobalFlashTestInt = 5678; #pragma CONST_SEG DEFAULT Daniel