S12G  local address and global address

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

S12G  local address and global address

4,214 Views
jinpengxiao
Contributor II

What is the meaning of  local address and global address .What is difference between local address and global address. How to convert them

Labels (1)
7 Replies

2,825 Views
RadekS
NXP Employee
NXP Employee

Hi Jinpeng,

S12 core works only with 16 addresses – therefore address space is limited to the 64kB address range.

If we want to access more than 64kB, we use memory window (for example 0x8000 to 0xBFFF) and paging mechanism where we switch pages in this window by PPAGE register.

So, local address contains page and physical address in 64kB space. For example local address 0x089000 means page 0x08 and address 0x9000 in 64kB space.

The next synonym for the Local address is Banked address.

On opposite site, a Global address describes memory space as one memory block without paging.

S12X core could work with these global addresses via specific global instructions – it saves execution time because paging presents overhead.

We also use global addresses for flash controller in case of S12 MCU built on 180nm technology (include S12G).

S12 core does not understand Global addresses – it still work inside their 64kB address space.

The next synonym for the Global address is Linear address.

In the attachment, you can find memory map for the S12G family in Excel sheet. You can use it for your reference. Please let me know whether you need such memory map file for different MCU family.

Conversion between Local (Banked) and Global (Linear):

I would like to recommend SRecCvt tool for address conversion.

The last version of SRecCvt is 1.0.31: https://www.nxp.com/webapp/sps/download/license.jsp?colCode=SRECCVTSW

Please use S12G240 for S12G derivatives or you could simply edit DeviceInfo.Dat and add your derivative

Another option is tool log2phy from PEmicro (login necessary)

http://www.pemicro.com/downloads/download_file.cfm?download_id=15

However, this tool converts only in one direction, from banked to linear format.

Note: CW debugger works only with S-record files with Local (Banked) addresses. The PEmicro tools work typically with S-record files with Global (Linear) addresses.

Here is simple routine for conversion Local (Banked) addresses to Global (Linear) at S12G:

/* Please Select derivative */

//#define _S12G128   /*only for S12G128*/

//#define _S12G96 /*only for S12G96*/

//#define _S12G64 /*only for S12G64*/

#define _S12G /*others for S12G*/

//==============================================================================

//Local2Global

//==============================================================================

unsigned long int Local2Global(unsigned long int address)

{

  //EEPROM

  if((address >= 0x0400) && (address <= 0x13FF))

  {

    address = (address + 0x4000) | 0x00010000;

    return address;

  }

/*******************************************************************************/

#ifdef _S12G128 /*only for S12G128*/

  //Unpaged P-Flash 0x1400 at S12G128

  if((address >= 0x1400) && (address <= 0x1FFF))

  {

    address = address | 0x00030000;

    return address;

  }

#endif /*_S12G128*/

#ifdef _S12G96 /*only for S12G96*/

  //Unpaged P-Flash 0x1000 at S12G96

  if((address >= 0x1000) && (address <= 0x1FFF))

  {

    address = address | 0x00030000;

    return address;

  }

#endif /*_S12G96*/

#ifdef _S12G64 /*only for S12G64*/

  //Unpaged P-Flash 0x0C00 at S12G64

  if((address >= 0x0C00) && (address <= 0x2FFF))

  {

    address = address | 0x00030000;

    return address;

  }

#endif /*_S12G64*/

/*******************************************************************************/

  //Unpaged P-Flash 0x4000 and 0xC000

  if(((address >= 0x4000) && (address <= 0x7FFF)) || ((address >= 0xC000) && (address <= 0xFFFF)))

  {

    address = address | 0x00030000;

    return address;

  }

  //Paged P-Flash 0x8000

  if((address >= 0x00018000) && (address <= 0x000FFFFF))

  {

    address = ((address >> 2) & 0x000F0000) | (((((address & 0x000F0000) >> 16)%4) * 0x4000) | (address & 0x00007FFF));

    return address;

  }

  return 0;

}


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

2,825 Views
jinpengxiao
Contributor II

Hi Radek Sestak

Thank you very much for your reply. 

what is meaning of  memory mapping . Is it mapping to physical address?

There is the notion of logical address and physical address whether or not  in MCU .

When I do not use the global address,the local address  will convert to global address automatically? C000~FFFF can be accessed directly , Is it physical address?   Can i think local address is logical address  and global address  is physical  address?local address convert to global address by S12 MMC? Finally,How to work S12 MMC ?The address bus  is only 16 bit . Why can the global address extended to 18 bit or more ?

Best regards

jinpeng

0 Kudos

2,825 Views
RadekS
NXP Employee
NXP Employee

Hi Jinpeng,

Addresses are not converted automatically.

Memory range 0xC000..0xFFFF refers to page 0x0F. So, memory range 0x0F8000..0x0FBFFF (local addresses) points to the same physical memory as non paged range 0xC000..0xFFFF.

Similar situation is valid also for page 0x0D and range 0x4000..0x7FFF.

Additionally S12G64, S12G96 and S12G128 have also mirrored part of page 0x0C into non banked memory range 0x0C00(0x1000, 0x1400)..0x2FFF(0x1FFF).

Typically we define just one of these options in linker file – either non-banked or banked memory ranges. Since the upper P-Flash sector contains interrupt and reset vectors, page 0x0F is always defined as nonbanked memory range 0xC000..0xFFFF.

Yes, we could say, that global address is the physical address. From this point of view, the memory mapping is mapping to physical addresses.

Yes, MMC module is responsible for address decoding. The content of PPAGE register extends address to 24bit mode from our point of view. We simply add this content (page) prior address from memory window. In fact, the compiler will just generate code for PPAGE register update prior access to the appropriate memory page.

The MMC module is responsible for switch memory content in window 0x8000..0xBFFF in the case of change PPAGE register value.

In fact, you need to thing about global addresses only when your code contains routines for write into P-flash. You need to convert the S-record file into global addresses only when you generate this file by CW and you want to program it via PEmicro tools like Prog12Z Flash Programmer software or CyclonePro (Cyclone Universal) in standalone mode.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

2,825 Views
giuseppedivella
Contributor I

Hello Radek,

i've found searching on the web this thread and it's very clear and interesting about memory addressing on HCS12. 

I would like, anyway, to verify with you if I understood fine... 

I've started to work on a firmware based on HCS12XEP100, which I compile and debug with CW 5.1 / 5.2. At the end of compiling, if I look at the content of the \bin\ folder, I can see that both <prj_out>.abs.s19 and <prj_out>.abs.glo have been generated, the latter bigger in size.

Doubt is: both extensions might be used to re-flash the uC, but .glo is the only one that works with PEmicro tools like Prog12Z Flash Programmer software or CyclonePro (Cyclone Universal). Correct? What should I chosse if I must use a serial protocol in the bootloader to program the core?

Thanks a lot

Giuseppe

0 Kudos

2,825 Views
RadekS
NXP Employee
NXP Employee

Hi Giuseppe,

You are right. When you build project for S12XE, <prj_out>.abs.s19 and <prj_out>.abs.glo files will been generated.

The s19 file will contain addresses in local format while glo file addresses in global format.

Both files are generated from abs file by burner.exe utility. The rules for generating these files are stored in burner.bbl file. The syntax documentation may be found in:

"c:\Program Files (x86)\Freescale\CWS12v5.2\Help\pdf\Build_Tools_Utilities.pdf"

 

Both files should contain the same information = Flash content. Both files use S-Records for data content description. The difference is just in addresses format.

 

 

In general, every tool typically accept only addresses in one specific format. The CW works with addresses in local format, while PEmicro tools like Prog12Z or CyclonePro in standalone mode expects addresses in global format.

 

The PEmicro offers log2phy tool for conversion s19 file to the phy file (you should get the same content as it is in glo file). NXP offers SRecCvt tool, which is more universal and may covert addresses in both directions. So, there should not be any problem with S-Record files conversion.

 

About bootloader)

The same situation as with programming tools – the bootloader typically understood just one type of S-Record address format. For example, AN4258 bootloader expects that addresses will be in global (linear) address format. This bootloader also expects that all S-Records will contain exactly 32 bytes. Therefore, SRecCvt tool is used for conversion s19 file.

I hope it helps you.

Radek

2,825 Views
jinpengxiao
Contributor II

Hi Radek Sestak

Thanks  

addressing by global address finally

If the CPU want o find a storage unit ,CPU use local address (page)and then by MMC eventually to global address, complete the process of addressing?(the  hardware convert)

If it is non paged sector (C000 - FFFF and 4000 - 8000)  skiping this step?  it will addressing storage unit by C000-FFFF or 4000 - 8000

Do you have S12 core document ?or explain the cpu addressing storage uint

Best regards

Jinpeng

0 Kudos

2,825 Views
RadekS
NXP Employee
NXP Employee

Hi Jinpeng,

Yes, your understanding is more-less correct.

In fact, CPU does not now know about any storage unit. S12 CPU simply works in 64kB address space and do not care about technology on the background. Therefore, CPU could execute code from any area in this memory range - RAM, EEPROM, FLASH or external bus (not for S12G case), or even from Registers.

Only your compiler/linker and you know about the world behind this 64kB address boundary. So, if your C code points to non-banked flash, compiler/linker will translate it into instructions which will handle PPAGE register and operate with addresses in memory window.

Note: There may be also other page registers like RPAGE (for RAM), EPAGE (for EEPROM), GPAGE (for global addresses), but they are not applied in the case of S12G. S12G use just PPAGE.

Please look at http://www.nxp.com/files/microcontrollers/doc/ref_manual/S12XCPUV2.pdf for more details about S12(X) core.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------