fab48

how to allocate and declare const string messages

Discussion created by fab48 on May 12, 2011
Latest reply on May 14, 2011 by kef

i need help,

i'm working on a project using microcontroler freescale MC9S12DT512  S12X familly

 

i need to put into the PAGE FE a big table of messages.

so inside my project i declare my table like it :

 

#pragma CONST_SEG   MYCONSTANTS 

 

#define mess_1_FRANCAIS   "HELLO WORLD"

#define mess_1_FRANCAIS   "I NEED HELP"

#define mess_1_FRANCAIS   "FOR MY PROGRAMM"

#define mess_1_FRANCAIS   "THANK YOU"

 

 char* __far const texte_menu_FRANCAIS[] = {
 
    mess_1_FRANCAIS,
    mess_2_FRANCAIS,
    mess_3_FRANCAIS,
    mess_4_FRANCAIS

}

 

#pragma CONST_SEG DEFAULT

 

So my constant table of messages was created and i put it inside a segment named MYCONSTANTS 

then i allocate this segment into the PAGE FE,

to do it i modify the PRM file of my project lije it :

 

PLACEMENT /* here all predefined and user segments are placed into the SEGMENTS defined above. */
    _PRESTART,
    STARTUP,
    ROM_VAR,
    NON_BANKED,
    COPY                               INTO    ROM_C000;
    DEFAULT_ROM             INTO    PAGE_E0, PAGE_E1, PAGE_E2, PAGE_E3, PAGE_E4, PAGE_E5, PAGE_E6, PAGE_E7,
                                                          PAGE_E8, PAGE_E9, PAGE_EA, PAGE_EB, PAGE_EC, PAGE_ED, PAGE_EE, PAGE_EF,
                                                          PAGE_F0, PAGE_F1, PAGE_F2, PAGE_F3, PAGE_F4, PAGE_F5, PAGE_F6, PAGE_F7,
                                                          PAGE_F8, PAGE_F9, PAGE_FA, PAGE_FB, PAGE_FC ;
    DEFAULT_RAM              INTO   RAM;
    DEFAULT_EEPROM      INTO   EEPROM1, EEPROM2;
    
    MYCONSTANTS, STRINGS        INTO PAGE_FE;
END

 

now, after compilation i obtain this in the MAP FILE :

 

- VARIABLES:
     STRING..20                                            FE89E1       1       1             2   .rodata1   
     STRING.NG120.FRANCAIS.21           FE89E2       F      15             2   .rodata1   
     STRING.V2.19.22                                 FE89F1       6       6              2   .rodata1   
     STRING.NIVEAU.23                              FE89F7       7       7              2   .rodata1   

     texte_menu_FRANCAIS                     FE8010     88E    2190       2   MYCONSTANTS

 

so we can see the const messages was inside the PAGE FE.

 

now i run my project with a debugger and i scope the  texte_menu_FRANCAIS  :

but when i expand my table texte_menu_français i can see the adress of each message

message 1 located at  0x7F89E1

message 2 located at  0x7F89E2

message 3 located at  0x7F89F1

message 4 located at  0x7F89F7

 

SO LOOK the begining of the address is not correct i obtain 0x7F for all messages instead of 0xFE

normally i must have oxFE because my map file indicate that messages are in the page FE.

 

SO i don't understand ????

 

to finish i have a function to access to messages with a classical pointer like it :

 

uint8 Find_String(uint8 lign, uint16 mes)
{
  uint8 txt,curseur;

  const char* __far ptr;

 


     ptr = texte_menu_FRANCAIS[mes];
      
     txt = 1;
    while(txt)        

   {
         txt = *ptr++;

  } 

 

so with my pointer i try to access to each letter of my messages but it doesn't work.

 

please could someone, an expert can help me i don't know what can i do now, i'm working on this proble since 3 days ..

 

fabrice

Outcomes