using __pptr

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

using __pptr

2,158 次查看
opener
Contributor I
Hi, i am using __pptr pointer type for assigning a object stored in the paged flash. do i need to predefine anything for using this __pptr? Because my code enters into indefinite loop in the init function of the start12_sc.c. Thanking you in advance
标签 (1)
0 项奖励
回复
3 回复数

1,145 次查看
CrasyCat
Specialist III
Hello

Which CPU are you targeting (HC12, HCS12, HCS12X, ...)?

Access to paged data or constants is pretty different for each of these cores.

CrasyCat
0 项奖励
回复

1,146 次查看
opener
Contributor I
i am using HCS12XDP512
0 项奖励
回复

1,146 次查看
CompilerGuru
NXP Employee
NXP Employee
Hi,

not sure what start12_sc.c is, I guess its derived from start12.c.
As your problem is inside of start12.c it has probably nothing to do with your use of __pptr, a few words about those later.
The most probably cause of this is that you are using paged variables, but you do not specify -D__FAR_DATA on the command line. By default, the startup code in the small and banked memory model is only handling non banked data. If you do allocate initilized variables banked, then use -D__FAR_DATA.
As __pptr is a pointer to a flash location, this is another issue.
Be sure when using __pptr pointers that your code is not executing out of the 0x8000..0xBFFF area as __pptr code can directly set PPAGE and that wont work outside of this area. With __far pointers you do not have this restriction, but they do generate more and slower code, so it depends on the application on what's better. __far pointers are definitely simpler and safer to use, tough.
And to finally also answer your question, once you have a __pptr pointer to a certain address, you can only use other __pptr or __far pointers to access the same memory. As soon as you use a normal, 16 bit pointer, then the page gets lost and you may access the wrong memory.

In general, I would prefer to use __far pointers over __pptr.

PS: If your __pptr usage is inside of this "start12_sc.c" already, then my diagnosis would be wrong and you probably did not place Init in a non banked area.

Daniel
0 项奖励
回复