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.
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!
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!
-----------------------------------------------------------------------------------------------------------------------
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.
Hi Jason,
the demo code is right under my last reply. see:
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!
-----------------------------------------------------------------------------------------------------------------------
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,
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!
-----------------------------------------------------------------------------------------------------------------------
You are welcome!
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
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
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!
-----------------------------------------------------------------------------------------------------------------------
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.
you are welcome!
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the "Mark Correct" button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jason,
Could you tell us which CodeWarrior version are you using?
Thanks in advance!
Best Regards,
Carlos Mendoza
Technical Support Engineer