Hello All,
I am working with MC9S12XEQ384 but I have some problem with Local Address and Global Address. How can we convert from Local Address to Global Address on MC9S12XEQ384 ?
Thank you so much!
Hi Huu,
if you need to convert P-Flash address, you may use followed code:
//==============================================================================
//Convert_Ppage2Global
//==============================================================================
unsigned long int Convert_Ppage2Global(unsigned long int Addr)
{
Addr = ((Addr>>2) & 0x003FC000UL) | (Addr & 0x00003FFFUL) | 0x00400000;
return(Addr);
}
Attached is S12XE memory map in excel sheet for your reference.
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Huu,
that is even easier:
//==============================================================================
//Convert_Rpage2Global
//==============================================================================
unsigned long int Convert_Rpage2Global(unsigned long int Addr)
{
Addr = ((Addr & 0x00FF0000UL)>>4) | (Addr & 0x00000FFFUL);
return(Addr);
}
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank Radek,
I have a concern, How can we use the RPAGE area ? How to initiate it to store data or code ?
Hi Huu,
As first, I would like to recommend look at our application note AN3784 Understanding the Memory Scheme in the S12(X) Architecture
http://www.nxp.com/files/soft_dev_tools/doc/app_note/AN3784.pdf
After that, please look at TN238 and TN240 PDFs in "c:\Program Files (x86)\Freescale\CWS12v5.2\Help\pdf\" directory.
In short, you may use linker directive “#pragma DATA_SEG” for placing variables into paged RAM. For example:
#pragma DATA_SEG PAGED_RAM
unsigned int my_counter = 0x1234;
//…
#pragma DATA_SEG DEFAULT
Note: PAGED_RAM section is defined by default in prm linker file. You may create your own section.
Note: You must add the option -D__FAR_DATA on the compiler command line for proper paged RAM variables initialization during startup.
Note: The #pragma CONST_SEG change default linker settings for constants. The #pragma CODE_SEG change default linker settings for code placement.
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------