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!
-----------------------------------------------------------------------------------------------------------------------