PPAGE Use Problem.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

PPAGE Use Problem.

1,512 次查看
timcuff
Contributor I

I am using a 9s12G128, CodeWarrior for the Code.  Banked Memory Model.  I have code in loaded into Page 8 (PPAGE 8), and data in Page 9 (PPAGE 9) . 

 

Can (banked) code running from Page 8 access data in Page 9?    When I run in the debugger, it seems that the data access to the Page 9 data changes the PPAGE register, but does change the PPAGE value back to Page 8 once the data read is complete.

 

Or, if you access data in Paged Flash, must the code be executing from non-paged memory?

标签 (1)
0 项奖励
回复
2 回复数

1,092 次查看
kef2
Senior Contributor V
timcuff,

It depends on what are you trying to achieve. Certainly it is possible to access data from paged memory, even while executing code in paged memory and when code is in paged memory on different page. Zhang's projects shows how it is doable. On non-S12X parts, for paged data accesses compiler makes call's to nonbanked routines, which switch PPAGE, read data from Ppage window, restore PPAGE, and then return to callee. This is slowish process. If it is too slow for you, then you should consider switching to S12X. Even on S12, you still have options to eliminate slow data access routines calls:

1) Access your data from routine executing in nonpaged memory. Don't forget to restore PPAGE before you return.

2) If amount of data is small and is less than one page (16k), then you may force linker to place both, data and data accessing routine(s) on the same page. This would eliminate the need to switch PPAGE. To do so, create new placement to specific Ppage in PRM file, then use pragmas to place both access routines and data in this placement. In contrast to Zhang's example data pragma should not include __PPAGE_SEG attribute. __PPAGE_SEG is what tells compiler to use PPAGE switching access routines. Without it you may do data accesses directly from access routine on the same ppage.

0 项奖励
回复

1,090 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

in banked memory mode, code is far(24bit) access while data is near(16bit) access by default.

so (banked) code can run from Page 8 access data in Page 9. but data can't. far keyword is necessary.

I attached my sample code of data accessing bank with assisting of far keyword, hope this helps!

0 项奖励
回复