what is GPAGE_SEG?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

what is GPAGE_SEG?

Jump to solution
1,522 Views
100asong
Contributor I

My MCU type:MC9S12X.

I don't know what GPAGE_SEG?

If I write

#pragma CONST_SEG _GPAGE_SEG myseg

const int16 myVar[2] = {0x01,0x02}

in Code,

I will find GPAGE_SEG in map file:myVar          D881       6       6       4   _GPAGE_SEG 

 

 

GPAGE_SEG is compiler known symbol,  But I don't find the defination and what is the exact meaning.

Labels (1)
0 Kudos
Reply
1 Solution
1,324 Views
kef
Specialist I

Unless there are special requirements, like the need to allocate ISR functions in nonbanked flash, it is more convenient to allocate code in default memory. 

Project wizard (in case you don't use Processor Expert) creates single placement record for all paged flash and calls it DEFAULT_ROM. Unless you have big >16k arrays of data, it makes sense to use this DEFAULT_ROM to allocate your constants. This may free you from the task of allocating data in specific flash pages. 

View solution in original post

0 Kudos
Reply
6 Replies
1,324 Views
kef
Specialist I

It tells compiler that global addressing (GPAGE register + gstaa/gldd etc CPU instructions) are should be used to access data, wich is allocated in memory segment you specify (myseg in your case).

Similarly __RPAGE_SEG is used to access paged RAM switching RPAGE register. __EPAGE_SEG for EPAGE paged EEPROM etc.

It shouldn't affect your map file. PRM file defines addresses of memory segments. Since compiler doesn't know at compile time where will be specific segments allocated, compiler need more information, and you help compiler specifying segment attributes like __GPAGE_SEG. This means that if some variables are accessed from different files, all source units should see not only extern variable declarations, but all those shared externs should be also declared in H-files between the same DATA_SEG pragmas

#pragma DATA_SEG xxxxx

put you vars here

#pragma DATA_SEG DEFAULT

 

0 Kudos
Reply
1,324 Views
100asong
Contributor I

Hi,Dear kef.

 

       Thanks for your help.

       

        I implement these work:

        In prm file:

        MySeg INTO PAGE_FE;

        MyCode INTO PAGE_FC;

        In my.c file:

        #pragma CONST_SEG __GPAGE_SEG MySeg

        const int sa[4] = {0x11, 0x12, 0x13, 0x14};

        #pragma CONST_SEG DEFAULT

 

        And then I want to access  sa in PAGE_FE flash area.

            

        int * __far g_psa;

        int x = 0;

         #pragma CODE_SEG MyCode

        void ReadSa()

        {

 

               g_psa = (int* __far)sa ;

               x = *(int * __far)g_psa++;//x = 0,not 0x11

               x = *(int * __far)g_psa++;//x = 0, not 0x12

               x = *(int * __far)g_psa++;//x = 0, not 0x13

               x = *(int * __far)g_psa;

        }

         #pragma CODE_SEG DEFAULT

          

         How to get the right data:0x11,0x12,0x13?

         How to access access 0xFE from page 0xFC?

 

         Thanks.

 

 

 

0 Kudos
Reply
1,324 Views
kef
Specialist I

But last write to x is working, right? If so, then compiler has optimized away unused stores to x. Try making x volatile.

 

I wonder what is purpose of storing your function in specific page of flash?

0 Kudos
Reply
1,324 Views
100asong
Contributor I

Try volatile is okay.

I want to store some constant data in one page of flash, and then I can access it.

0 Kudos
Reply
1,325 Views
kef
Specialist I

Unless there are special requirements, like the need to allocate ISR functions in nonbanked flash, it is more convenient to allocate code in default memory. 

Project wizard (in case you don't use Processor Expert) creates single placement record for all paged flash and calls it DEFAULT_ROM. Unless you have big >16k arrays of data, it makes sense to use this DEFAULT_ROM to allocate your constants. This may free you from the task of allocating data in specific flash pages. 

0 Kudos
Reply
1,324 Views
100asong
Contributor I

So good.

0 Kudos
Reply