using __pptr

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

using __pptr

2,157件の閲覧回数
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,144件の閲覧回数
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,145件の閲覧回数
opener
Contributor I
i am using HCS12XDP512
0 件の賞賛
返信

1,145件の閲覧回数
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 件の賞賛
返信