Read data on paged flash

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

Read data on paged flash

1,273 Views
jasoncui
Contributor II

Why the data read in paged area was always 0xff (the real data was not 0xff)? and the data which in non-paged was read ok. The MCU I used was MCS912G128.

Any help would be much appreciated.

Labels (1)
0 Kudos
14 Replies

964 Views
jasoncui
Contributor II

Another question on read data from other paged flash.

My code is stored in C0 paged flash, and want to read data from the address which is in C1 paged flash.

And the code is like as follows:

.....................

page_backup = PPAGE;

PPAGE = C1;

           

data = *ptr;

           

/*

     Restore the PPAGE value

*/

PPAGE = page_backup;

.....................

When the “PPAGE = C1;” is executed, the system would be broken down. What's the reason about this?

I forgot to say the MCU is mc9s12xep100, and the CodeWarrior version is 5.9.0.

Any help would be much appreciated!

0 Kudos

964 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi,

to access memory from one page to another, we need use far pointer.

see attached demo code.


Have a great day,
Jennie Zhang

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

0 Kudos

964 Views
jasoncui
Contributor II

Hi, Jennie

Where the demo do you attached? I can't find it in this page.

Actually, I want to know what's wrong with my code. Does "PPAGE" can't be
accessed directly by this way? But, the same code is run normally in MCS912G128.

Thanks.

0 Kudos

964 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Jason,

the demo code is right under my last reply. see:

pastedImage_0.png

couldn't you see it? if not, pls tell me your email, I will send it to you via email.

basically HCS12(x) is 16bit MCU, the default address access is 16bit. if we want to access other paged address, we must use qualifier to extend the address access pointer to over 16bit.


Have a great day,
Jennie Zhang

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

0 Kudos

964 Views
jasoncui
Contributor II

Hi, Jennie

I declaration a global pointer with "__far" qualified. And the result was incorrect.

The code as follows:

unsigned char *__far ptr;

unsigned long addr;

unsigned char temp_data[32];

unsigned char i;

addr = 0xC98560;

ptr = (unsigned char *)addr;

/* read programmed data */

for (i = 0; i < 32; i++)

{

     temp_data[i] = *ptr;

     ptr++;

}

The code is stored in $C0 page. I see in watch table the ptr value is 0x700560 (local address is:0xC08560) after "ptr = (unsigned char *)addr;"

is executed, it should be 0x724560. What's wrong with my code? And I still confused why PPAGE can't be accessed directly as I described before,

did I miss something?

Thanks.

Regards,

0 Kudos

964 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Jason,

Please refer to the sample code to implement your project.

I just sent it to you to g_fjcui@126.com.


Have a great day,
Jennie Zhang

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

0 Kudos

964 Views
jasoncui
Contributor II

Hi, Jennie

Got it! Thanks you.

0 Kudos

964 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

You are welcome!

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

0 Kudos

964 Views
jasoncui
Contributor II

Hi, Jennie

I can't see your attachment, could you send it to me by email? My email address is: g_fjcui@126.com.

Can't the data be read by my way as the code showed above? And why?

And why assign value to PPAGE can cause program run away?

Thanks

0 Kudos

964 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Jason.

My colleague ever developed a demo code including how to access paged memory of 9s12g128. can you please refer to attached demo code.

can it help you?


Have a great day,
Jennie Zhang

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

0 Kudos

964 Views
jasoncui
Contributor II

Hi, Carlos

The CodeWarrior version I used is 5.9.

Forget to tell you, I have resolved the issue.

Thanks a lot.

0 Kudos

964 Views
jasoncui
Contributor II

Hi, Jennie

I have found the cause and resolved the issue with my way before I saw your information.

I didn't run your demo code, but I think it should be worked, because I could read correct data from

paged memory with other way similar yours.

Thanks a lot.

0 Kudos

964 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

you are welcome!

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

0 Kudos

964 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Jason,

Could you tell us which CodeWarrior version are you using?

Thanks in advance!

Best Regards,

Carlos Mendoza

Technical Support Engineer

0 Kudos