Memory Mapping with MC9S12DJ256

cancel
Showing results for 
Search instead for 
Did you mean: 

Memory Mapping with MC9S12DJ256

322 Views
adamgann
Contributor I

Hello Everyone,

 

I'm just starting off some work with the S12 series, specifically the DJ256. I am working out the memory mapping for the RAM, EE, and Registers.

Would someone with some more experience be able to comment if anything looks out of place?

 

My tentative configuration is:

 

 

INITEE     0x01     EEPROM mapped to 0x0000 - 0x0xFFF (4kB) and enabled

INITRM    0x39     RAM mapped to 0x1000 - 0x3FFF (12kB) and high-aligned

INITRG     0x40     Registers mapped to 0x4000 - 0x4800 (2kB)

 

 

Does this look okay? Is there a better configuration? And lastly, am I correct that the ROMHM bit in the MISC register should

be left at its default (unset, lower-half EE/ROM can be accessed)? I'd appreciate any help, thanks!

 

 

Adam

Labels (1)
0 Kudos
2 Replies

109 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

Once I remapped the memory in bellow mentioned way.  Your approach is good because it takes only 2KB from nonpaged memory 4000. My approach takes 4KB from this memory because I placed an EEPROM there. Moreover, I would like to present some facts to be taken into account in the CodeWarrior environment.

Some comments to your setup:

OK;   INITEE 0x01     EEPROM mapped to 0x0000 - 0x0xFFF (4kB) and enabled

OK;  INITRM 0x39     RAM mapped to 0x1000 - 0x3FFF (12kB) and high-aligned ( first block selected, up alligned)

comment: the same  is INITRM 0x01     RAM mapped to any 16 k block 0x1000 - 0x3FFF (12kB) and high-aligned

OK;  INITRG 0x40     Registers mapped to 0x4000 - 0x4800 (2kB)  0x4000 - 0x43FF

comment: the RAM occupies only 1K so it is mapped at 0x4000 - 0x43FF

The project representing my setup is attached. It is made for the compatible MCU with the same memory map. The main facts are highlighted bellow.

1) main.c module

//The Memory is remapped in following way

//

//- Registers     : 0000~03FF

//- RAM           : 1000~3FFF

//- EEPROM        : 4000~4FFF

//- Unpaged flash : 5000~7FFF, C000~FFFF

//- Paged   flash : 0x(30~3F)(8000~BFFF)

//

//Remapping is made in the file Start12.c before Init() function is called.

//(Init() function is automatically generated by CodeWarrior to initialize variables)

//

//

// //-----------------------------------

//  folowing lines are placed inside Start12.c to define memory map (line 413)

//  *(unsigned char*)0x11 = 0x00;   // INITRG = 0x00; Set the Reg map position     0x0000~0x03FF

//  asm nop;                      // recommended

//  *(unsigned char*)0x10 = 0x01;   // INITRM = 0x01; Set the RAM map position     0x1000~0x3FFF

//  *(unsigned char*)0x12 = 0x41;   // INITEE = 0x41; Set the EEPROM map position  0x4000~0x4FFF, EEON=1

// //------------------------------------

//

//  Also *.prm file must be adjusted to meet these changes. (See line 11 and 18 in the prm file)

2) PRM file lines 11-18:

__EXTERN_C void _Startup(void) {

#endif

/*  purpose:    1) initialize the stack

2)  initialize the RAM, copy down init data etc (Init)

3)  call main;

    parameters: NONE

    called from: _PRESTART-code generated by the Linker

                 or directly referenced by the reset vector */

  *(unsigned char*)0x11 = 0x00;     // INITRG = 0x00; Set the Reg map position 0x0000~0x03FF

  asm nop;                      // recommended

  *(unsigned char*)0x10 = 0x01;     // INITRM = 0x01; Set the RAM map position 0x1000~0x3FFF

  *(unsigned char*)0x12 = 0x41;     // INITEE = 0x41; Set the EEPROM map position 0x4000~0x4FFF, EEON=1

3) PRM file changes:

/* Register space  */

/*    IO_SEG        = PAGED         0x0000 TO   0x03FF; intentionally not defined */

/* EPROM */

//    EEPROM        = READ_ONLY     0x0400 TO 0x0FEF;

      EEPROM        = READ_ONLY     0x4000 TO 0x4FEF;

/* RAM */

      RAM           = READ_WRITE    0x1000 TO 0x3FFF;

/* non-paged FLASHs */

//    ROM_4000      = READ_ONLY     0x4000 TO 0x7FFF;

      ROM_4000      = READ_ONLY     0x5000 TO 0x7FFF;

Please look into attachment to check it.

Best regards,

Ladislav

0 Kudos

109 Views
adamgann
Contributor I

Ladislav,


Thank you very much for the help!



Adam

0 Kudos