Problem of writting PPAGE

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

Problem of writting PPAGE

665 Views
jasoncui
Contributor II

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.

Labels (1)
0 Kudos
4 Replies

554 Views
RadekS
NXP Employee
NXP Employee

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:

  1. Keep automatic modification of pages (PPAGE, GPAGE) by compiler/linker – use far pointers, compiler option -CpPPAGE=RUNTIME (routines from datapage.c),…
  2. Use own non-paged routines for manipulations with PPAGE.

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

554 Views
jasoncui
Contributor II

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!

0 Kudos

554 Views
RadekS
NXP Employee
NXP Employee

Hi Jason,

You're welcome.

I am glad that the problem has been resolved.

I wish you good luck in the future development.

Have a great day,
RadekS

0 Kudos

554 Views
kef2
Senior Contributor V

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.