How to use >32k of flash?

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

How to use >32k of flash?

Jump to solution
2,869 Views
Anders
Contributor I
Hi there,
I'm using the MC9S12GC64. Just recently the code size has grown above 32k, and therefor I have upgraded to Code Warrior V4.6 with a license to link 64k of code.
 
This is how my .prm file has looked up until now. I have only used the non banked ROM. (The RAM setup in Start12.c is according to the serial monitor example.)
 
Code:
...SEGMENTS    RAM = READ_WRITE 0x3000 TO 0x3FFF;                /* unbanked FLASH ROM */    ROM_4000 = READ_ONLY  0x4000 TO 0x7FFF;       ROM_C000 = READ_ONLY  0xC000 TO 0xFEFF;              /* banked FLASH ROM */    PAGE_3C = READ_ONLY  0x3C8000 TO 0x3CBFFF;                              PAGE_3D = READ_ONLY  0x3D8000 TO 0x3DBFFF;ENDPLACEMENT    _PRESTART, STARTUP,    ROM_VAR, STRINGS,    VIRTUAL_TABLE_SEGMENT,    DEFAULT_ROM, NON_BANKED,    COPY                                             INTO  ROM_4000, ROM_C000;     OTHER_ROM                    INTO  PAGE_3D, PAGE_3C;                   DEFAULT_RAM                  INTO  RAM;ENDSTACKSIZE 0x100

Now I obviously need to do something to be able to go above 32k. One way would be to use the banked ROM. I suppose I then would need to use pragma directives to move e.g. constants to page 3c and 3d, right? I have fiddled a lot with this but have not been able to get it to work. What do I need to do with registers like PPAGE etc. in the Start12.c file?? How do I use the pragma directives? Can I just define any code like this:
 
#pragma CODE_SEG OTHER_ROM // Banked
...
static const signed int myVar[400]=....
...
#pragma CODE_SEG DEFAULT // back to non banked
 
Or have I completely misunderstood??
 
 
Also, I searched the forums here and found another idea: a linear mapping model that would allow for 48k of non banked memory. This would definately cover my needs and sounds very attractive and simple. However, I tried to add this to the .prm file:
 
ROM_8000 = READ_ONLY  0x8000 TO 0xBFFF;  
I did manage to compile and link but have not got the code to run. Again, I read that it might be that this area are is not flashed??
 
If I could keep everything within non banked 48k of ROM, I think I would prefer that, but any help would be appreciated. There has been many postings about memory mapping but I fear that I might lack the basic understanding to use the information I have found so far.
 
Thanks,
Anders
 
Labels (1)
Tags (1)
0 Kudos
1 Solution
849 Views
CompilerGuru
NXP Employee
NXP Employee
>#pragma CODE_SEG OTHER_ROM // Banked
...
>static const signed int myVar[400]=....

does not work because #pragma CODE_SEG only applies to code, and not to constants.
There is a similar #pragma CONST_SEG too, but I would check first if you need banked constants anyway. Placing code on banks is pretty simple, either start up with the banked memory model (where you need to place interrupt handlers explicitly non banked) or
place all the functions into a
#pragma CODE_SEG __FAR_SEG OTHER_ROM
area (also the declarations, not just the definitions!).

Basically the S12's support to place code banked quite nicely and the overhead is small.
Placing data or constants into banks works too, but the overhead for doing this is larger, so best if you only need banked code.


Daniel

View solution in original post

0 Kudos
6 Replies
849 Views
kef
Specialist I
Anders,
 
Nonbanked 48k of flash works on all S12 and S12X derivatives, except those that have less than 48k of flash.
 
Using S12C family members bigger than C32, you have more than 48k of non banked flash. C64 has 4k of RAM. RAM defaults to addresses 0-0xFFF (INITRM is set to 0x9 out of reset). So default nonpaged C64 memory map is as follows:
 
0000-03FF  - registers
0400-0FFF -  3k of visible RAM (register block hides remaining 1k of RAM)
1000-FFFF - 60k of flash
 
 
 
0 Kudos
850 Views
CompilerGuru
NXP Employee
NXP Employee
>#pragma CODE_SEG OTHER_ROM // Banked
...
>static const signed int myVar[400]=....

does not work because #pragma CODE_SEG only applies to code, and not to constants.
There is a similar #pragma CONST_SEG too, but I would check first if you need banked constants anyway. Placing code on banks is pretty simple, either start up with the banked memory model (where you need to place interrupt handlers explicitly non banked) or
place all the functions into a
#pragma CODE_SEG __FAR_SEG OTHER_ROM
area (also the declarations, not just the definitions!).

Basically the S12's support to place code banked quite nicely and the overhead is small.
Placing data or constants into banks works too, but the overhead for doing this is larger, so best if you only need banked code.


Daniel
0 Kudos
849 Views
Anders
Contributor I
Thanks very much. I have now placed the code (and not the constants) in OTHER_ROM, and that seems to be working just fine.
 
Again, thanks for pointing me in the right direction.
 
Anders.
0 Kudos
849 Views
Anders
Contributor I
Hello,
It seems I have a couple of issues with the banked model after all.
 
I'd really like to get the 48k nonbanked model working for comparison.....
 
I assume it's the page window  (8000-BFFF) that I cannot use as non banked. I believe however that I should be able to relocate the ram area to 8000-8FFF.
 
In addition to the nonbanked:
    ROM_4000 = READ_ONLY  0x4000 TO 0x7FFF;  
    ROM_C000 = READ_ONLY  0xC000 TO 0xFEFF;
 
I imagined I'd be able to use this area above the registers:
    ROM_0400 = READ_ONLY  0x0400 TO 0x3FFF;
 
Everything is linked all right, no warnings, but the code does not run.
 
I'm using an inDart-One programmer, and when I look at the memory window it seems the area 1000-3FFF consists entirely of FF's. Also, the actual flashing from CodeWarrior looks different from what it normally does. It starts with "Loading 37342 Bytes...." for a couple of seconds before the actual flashing takes place. I'm not sure if that is a clue...
 
Does anybody know what I'm doing wrong here?
 
Anders.
 


Message Edited by Anders on 2008-04-20 07:33 PM
0 Kudos
849 Views
bbowling
Contributor I
Did you ever get this working? I am experiencing a similar issue...

- Bruce
0 Kudos
849 Views
Anders
Contributor I
Hi Bruce.
Yes, I believe I got the compiling/linking/flashing bit to work, but I'm experiencing performance issues, so in the end I settled for only using the 32k.
 
Here's the solution given to me by Freescale:
 
"... The previous solution I mention was not useful as there was no possibility to debug the code. So finally the one possible solution is just include the PAGE_3C segment into your default placements :

PLACEMENT

_PRESTART, STARTUP,

ROM_VAR, STRINGS,

VIRTUAL_TABLE_SEGMENT,

DEFAULT_ROM , NON_BANKED,

COPY INTO ROM_C000,

ROM_4000,PAGE_3C;

(please notice the order of segments!)

And to ensure the correct PPAGE register settings you have to modify Start12c file (_Startup function)

___INITRM = 0x39; /* lock Ram to end at 0x3FFF */

/* new line to set the correct PPAGE register value */ *(unsigned char *)0x30 = 0x3C;

 

#ifdef _HCS12_SERIALMON

/* for Monitor based software remap the RAM & EEPROM to adhere

to EB386. Edit RAM and EEPROM sections in PRM file to match these. */

___INITRG = 0x00; /* lock registers block to 0x0000 */

___INITRM = 0x39; /* lock Ram to end at 0x3FFF */

___INITEE = 0x09; /* lock EEPROM block to end at 0x0fff */ #endif "

 

Hope this helps,

Anders.

0 Kudos