Hi, all
I have an application that's reading data back from programmed flash. I'm using the CW of version 5.9.0, and the chip
is MC9S12XEP100. The application code is stored in $C0 page, and the programmed flash is $C1, before read data, I assign the 0xC1 to PPAGE, but the assignment can result in program run away. I can't find what's wrong with PPAGE assignment, can't PPAGE be accessed directly, or I miss something? Does anybody else has the same situation? The code I pasted below. Any help would be greatly appreciated!
..........................................
U8 temp_data[32];
U8 * ptr;
U8 page;
U8 page_backup;
U32 addr;
addr = 0xC18560;
ptr = (U8 *)(addr & 0xFFFF);
page = (U8)(addr >> 16);
if (page)
{
page_backup = PPAGE;
PPAGE = page;
}
.................................................
PS:
The same code is run ok in MC9S12G128. In this application, code is placed in 0 page.
Hi Jason,
As correctly mentioned by Edward, this code could work only when this code is executed from unbanked memory. When code runs from banked memory, we cannot modify PPAGE directly.
So, we should decide for one of followed options:
What is not clear to me for now: “In this application, code is placed in 0 page.”
S12G128 have PPAGE in range 0x08~0x0F (and potentially also 0x01 for Flash IFR)
S12XEP100 have PPAGE in range 0xC0~0xFF
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!
-----------------------------------------------------------------------------------------------------------------------
Hi, Edward & RadekS
"0 page" is a mistake in writing, it should be non-paged:smileywink:
I placed the routine which manipulate the PPAGE in non-paged flash, and it works well.
You do me a great favor.
Thanks you very much!
Changing PPAGE contents while executing routine located in paged flash causes runaway. Try reading how code paging is supposed to work. CPU manual is good starting point.
To read paged memory either use global addressing or jump to nonpaged routine and manipulate PPAGE from there.