Information about Banked memory model on MC9S08QE64

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

Information about Banked memory model on MC9S08QE64

Jump to solution
1,033 Views
Stipey75
Contributor I

Hi!

 

A stupid question i suppose....:smileyhappy:

 

This is my Prm file:

 

NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */

SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
    Z_RAM                    =  READ_WRITE   0x0080 TO 0x00FF;
    RAM                        =  READ_WRITE   0x0100 TO 0x107F;
    /* unbanked FLASH ROM */
    ROM                             =  READ_ONLY    0x2080 TO 0x7FFF;
    ROM1                          =  READ_ONLY    0xC000 TO 0xFFAD;
 /* INTVECTS                 =  READ_ONLY    0xFFC0 TO 0xFFFF; Reserved for Interrupt Vectors */
    /* banked FLASH ROM */
    PPAGE_0                  =  READ_ONLY    0x008000 TO 0x00A07F; /* PAGE partially contained in ROM segment */
    PPAGE_2                  =  READ_ONLY    0x028000 TO 0x02BFFF;
    PPAGE_1                  =  READ_ONLY    0x018000 TO 0x01BFFF; //PAGE already contained in segment at 0x4000-0x7FFF */
    PPAGE_3                  =  READ_ONLY    0x038000 TO 0x03BFFF; //PAGE already contained in segment at 0xC000-0xFFFF */
END

PLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */
    DEFAULT_RAM                         /* non-zero page variables */
                                        INTO  RAM;

    _PRESTART,                          /* startup code */
    STARTUP,                            /* startup data structures */
    ROM_VAR,                            /* constant variables */
    STRINGS,                            /* string literals */
    VIRTUAL_TABLE_SEGMENT,              /* C++ virtual table segment */
    NON_BANKED,                         /* runtime routines which must not be banked */
    COPY                                /* copy down information: how to initialize variables */
                                        INTO  ROM; /* ,ROM1: To use "ROM1" as well, pass the option -OnB=b to the compiler */
    
    DEFAULT_ROM, PAGED_ROM                           /* routines which can be banked */
                                        INTO  PPAGE_0,PPAGE_1,PPAGE_2,PPAGE_3,ROM1;

    _DATA_ZEROPAGE,                     /* zero page variables */
    MY_ZEROPAGE                         INTO  Z_RAM;
END


STACKSIZE 0xC0

 

What i don't understand is...can i use PPage1 and PPagge3 in placement section? This comment confuse me...//PAGE already contained in segment at 0x4000-0x7FFF it seems that they refers to the same memory locations of ROM sections.

 

My code now is quite big about 50 Kb and when I use BDM to download code during the memory check in Hi Wave i receive error 51. But if I use PPAGE1 and PPAge3 everything is fine.


Can i use this line in PRM:

 

DEFAULT_ROM, PAGED_ROM                           /* routines which can be banked */
                                        INTO  PPAGE_0,PPAGE_1,PPAGE_2,PPAGE_3,ROM1;

or is making some troubles???

 

thanks


Labels (1)
0 Kudos
1 Solution
445 Views
kef
Specialist I

Following nonbaked and banked segments physically are the same memory:

 

nonbanked          =    banked

0x2080-0x3FFF  =  0x0A080-0x0BFFF  // ppage 0

0x4000-0x7FFF = 0x18000-0x1BFFF   // ppage 1

0xC000-0xFFFF = 0x38000-0x3BFFF  // ppage 3

 

You can add whole PPAGE_1 and most of PPAGE_3 to default paged ROM placement, but then you should remove corresponding nonbanked memory from NON_BANKED placement, else at some point you will have problems with flashing your codes to the chip. Write different codes twice to the same memory won't work.

You always need some nonpaged memory for ISR routines and some run time routines from library. Here's modified PRM file (hope it's stupid mistake-free). Almost 8k of nonbanked flash, 64-8k of banked:

 

 

NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */

SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
    Z_RAM                    =  READ_WRITE   0x0080 TO 0x00FF;
    RAM                        =  READ_WRITE   0x0100 TO 0x107F;
    /* unbanked FLASH ROM */
    ROM                             =  READ_ONLY    0x2080 TO 0x3FFF;      /*TO 0x7FFF; ppage1 is used for banked code*/
   /* ROM1                          =  READ_ONLY    0xC000 TO 0xFFAD;*/
 /* INTVECTS                 =  READ_ONLY    0xFFC0 TO 0xFFFF; Reserved for Interrupt Vectors */
    /* banked FLASH ROM */
    PPAGE_0                  =  READ_ONLY    0x008000 TO 0x00A07F; /* PAGE partially contained in ROM segment */
    PPAGE_2                  =  READ_ONLY    0x028000 TO 0x02BFFF;
    PPAGE_1                  =  READ_ONLY    0x018000 TO 0x01BFFF; /* this is the same like nonbanked 0x4000-0x7FFF */
    PPAGE_3                  =  READ_ONLY    0x038000 TO 0x3BFAD; /* vectors are at 0xFFAE(banked 0x3BFAE*/ 0x03BFFF;*/ /* this is the same like nonbanked 0xC000-0xFFFF */
END

PLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */
    DEFAULT_RAM                         /* non-zero page variables */
                                        INTO  RAM;

    _PRESTART,                          /* startup code */
    STARTUP,                            /* startup data structures */
    ROM_VAR,                            /* constant variables */
    STRINGS,                            /* string literals */
    VIRTUAL_TABLE_SEGMENT,              /* C++ virtual table segment */
    NON_BANKED,                         /* runtime routines which must not be banked */
    COPY                                /* copy down information: how to initialize variables */
                                        INTO  ROM; /* ,ROM1: To use "ROM1" as well, pass the option -OnB=b to the compiler */
    
    DEFAULT_ROM, PAGED_ROM                           /* routines which can be banked */
                                        INTO  PPAGE_0,PPAGE_1,PPAGE_2,PPAGE_3;

    _DATA_ZEROPAGE,                     /* zero page variables */
    MY_ZEROPAGE                         INTO  Z_RAM;
END

 


STACKSIZE 0xC0

 

 

View solution in original post

0 Kudos
4 Replies
446 Views
kef
Specialist I

Following nonbaked and banked segments physically are the same memory:

 

nonbanked          =    banked

0x2080-0x3FFF  =  0x0A080-0x0BFFF  // ppage 0

0x4000-0x7FFF = 0x18000-0x1BFFF   // ppage 1

0xC000-0xFFFF = 0x38000-0x3BFFF  // ppage 3

 

You can add whole PPAGE_1 and most of PPAGE_3 to default paged ROM placement, but then you should remove corresponding nonbanked memory from NON_BANKED placement, else at some point you will have problems with flashing your codes to the chip. Write different codes twice to the same memory won't work.

You always need some nonpaged memory for ISR routines and some run time routines from library. Here's modified PRM file (hope it's stupid mistake-free). Almost 8k of nonbanked flash, 64-8k of banked:

 

 

NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */

SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
    Z_RAM                    =  READ_WRITE   0x0080 TO 0x00FF;
    RAM                        =  READ_WRITE   0x0100 TO 0x107F;
    /* unbanked FLASH ROM */
    ROM                             =  READ_ONLY    0x2080 TO 0x3FFF;      /*TO 0x7FFF; ppage1 is used for banked code*/
   /* ROM1                          =  READ_ONLY    0xC000 TO 0xFFAD;*/
 /* INTVECTS                 =  READ_ONLY    0xFFC0 TO 0xFFFF; Reserved for Interrupt Vectors */
    /* banked FLASH ROM */
    PPAGE_0                  =  READ_ONLY    0x008000 TO 0x00A07F; /* PAGE partially contained in ROM segment */
    PPAGE_2                  =  READ_ONLY    0x028000 TO 0x02BFFF;
    PPAGE_1                  =  READ_ONLY    0x018000 TO 0x01BFFF; /* this is the same like nonbanked 0x4000-0x7FFF */
    PPAGE_3                  =  READ_ONLY    0x038000 TO 0x3BFAD; /* vectors are at 0xFFAE(banked 0x3BFAE*/ 0x03BFFF;*/ /* this is the same like nonbanked 0xC000-0xFFFF */
END

PLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */
    DEFAULT_RAM                         /* non-zero page variables */
                                        INTO  RAM;

    _PRESTART,                          /* startup code */
    STARTUP,                            /* startup data structures */
    ROM_VAR,                            /* constant variables */
    STRINGS,                            /* string literals */
    VIRTUAL_TABLE_SEGMENT,              /* C++ virtual table segment */
    NON_BANKED,                         /* runtime routines which must not be banked */
    COPY                                /* copy down information: how to initialize variables */
                                        INTO  ROM; /* ,ROM1: To use "ROM1" as well, pass the option -OnB=b to the compiler */
    
    DEFAULT_ROM, PAGED_ROM                           /* routines which can be banked */
                                        INTO  PPAGE_0,PPAGE_1,PPAGE_2,PPAGE_3;

    _DATA_ZEROPAGE,                     /* zero page variables */
    MY_ZEROPAGE                         INTO  Z_RAM;
END

 


STACKSIZE 0xC0

 

 

0 Kudos
445 Views
CompilerGuru
NXP Employee
NXP Employee

While the setup is correct, but it introduces unnecesary limitations.

Instead, do not use PPAGE_1, PPAGE_3 and list ROM (full one, ending at 0x7FFF) and ROM1 at the end of the DEFAULT_ROM placement. Banked code/data has no issue to run from non banked memory.

 

That setup has multiple advantages.

- it will still work if the unpaged code needs more than the 8k

- if the unpaged code does not fill up ROM, then that remaining space is automatically available for paged code as well.

- It also allows to move often used functions into NON_BANKED without having to manually adapt the prm.

  (basically no need to move the 0x4000 boundary to match the applications non banked needs)

 

Daniel

0 Kudos
445 Views
Stipey75
Contributor I

Thanks a lot guys!

 

It was like I supposed! The strange thing was the error i have when I flash the micro...ERROR 51 by hiwave it seems a verify flash error and it disappears when I use other pages, but your suggested prm make me more calm regarding erros on memory...

 

Now I try...

0 Kudos
445 Views
CompilerGuru
NXP Employee
NXP Employee

Do not use PPAGE_1 or PPAGE_3, comment them out.

PPAGE_1 is the same memory as a part of ROM, PPAGE_3 maps to ROM1.

If you run out of space in DEFAULT_ROM, you can list ROM in that placement as well:

DEFAULT_ROM, PAGED_ROM INTO  PPAGE_0,PPAGE_2,ROM1, ROM;

 

That will use the remaining of ROM for DEFAULT_ROM. It is a bit more efficient to make functions __NEAR  and place them into NON_BANKED.

 

Daniel

0 Kudos