Accessing an Address from the PAGED Address location

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

Accessing an Address from the PAGED Address location

跳至解决方案
1,641 次查看
Nycil
Contributor I

Am using a S12XEP100 microcontroller, I need to access an address at address location 0xF78000. I tried the normal way of accessing.

int* LocalVar = (int*)(0xF78000);

When I pass the LocalVar to a function, value @ address location 0x8000 is taken instead of 0xF78000. How do I solve this problem? My guess, am trying to access an address from a paged location.

Please Help

Thanks in Advance.

标签 (1)
0 项奖励
回复
1 解答
979 次查看
kef
Specialist I

datapage.c should be listed in project window, expand Sources tree and it should be there. If not, then it should be still on your disk in your project\Sources folder. Add this file back to the project. If not on the disk - create new project using new project wizard.

 

Do you pass LocalVar pointer to crc() or some other routines, which accept only near (non far) pointer? This won't work, unless you set up PPAGE (to 0xF7 in case of data at 0xF78000) somewhere in your code.

 _CONV_GLOBAL_TO_NEAR routine should not be referenced. It doesn't make sense to convert ppage-banked address to near pointer, since ppage information will be lost. You have banked address 0xF78000 (global 7DC000'G). After conversion to near pointer you will get only 0x8000, no information about PPAGE.

 

在原帖中查看解决方案

0 项奖励
回复
6 回复数
979 次查看
kef
Specialist I

Compiler treats address constant as global address. And it seems you are specifying PPAGE banked address. To convert from PPAGE-banked address to global you may macro like this:

 

#define ppage2global(x) (((x>>16)+0x100)*0x4000ul + (x & 0x3fff))

Also, unless you are using large memory model, you should use far keyword:

 

int * far LocalVar = (int * far)ppage2global(0xF78000);

 

0 项奖励
回复
979 次查看
Nycil
Contributor I

Thanks Kef. But I keep getting compiler error messages saying

ERROR L1822: Symbol _CONV_GLOBAL_TO_NEAR in file ../Obj/tel_mee_obc_dcdc_appln\romtst_svc.o is undefined

when I did as you had suggested.

 

Is this because I have to include a compiler option -Cp to facilitate "paged data access runtime routines" ? If so how do I include the compiler option?

 

When I gave as :

        uint8_t * LocalVar = (uint8_t * far)ppage2global(0xF78000);

It compiled ok , but it gave the same result as I had told in the first post.

 

Thanks in Advance

0 项奖励
回复
979 次查看
kef
Specialist I

_CONV_GLOBAL_TO_NEAR is defined in datapage.c, which be default is added to every project. Did you remove it from your project tree?

 

But this convert to routine shouldn't be called. It is called because your pointer is pointer to near object. Add missing far keyword and it should start working:

 

        uint8_t * far LocalVar = (uint8_t * far)ppage2global(0xF78000);

0 项奖励
回复
979 次查看
Nycil
Contributor I

Thanks Kef.

I guess, I have removed it from my project tree or it never was added to it.

Two Questions:

1) How Do I add "_CONV_GLOBAL_TO_NEAR" to the project tree?

2) What do you mean by the project tree? Is it the makefile you are refering to?  I am a newbie to embedded programming. Please contribute.

Thanks in Advance.

I need to access the data from the address 0xF78000 upto another address, say 0xF780FF. Its required for finding the CRC of the data present in this address range. This is my requirement fow which I need to access the data at the address 0xF780FF.

 

 

0 项奖励
回复
980 次查看
kef
Specialist I

datapage.c should be listed in project window, expand Sources tree and it should be there. If not, then it should be still on your disk in your project\Sources folder. Add this file back to the project. If not on the disk - create new project using new project wizard.

 

Do you pass LocalVar pointer to crc() or some other routines, which accept only near (non far) pointer? This won't work, unless you set up PPAGE (to 0xF7 in case of data at 0xF78000) somewhere in your code.

 _CONV_GLOBAL_TO_NEAR routine should not be referenced. It doesn't make sense to convert ppage-banked address to near pointer, since ppage information will be lost. You have banked address 0xF78000 (global 7DC000'G). After conversion to near pointer you will get only 0x8000, no information about PPAGE.

 

0 项奖励
回复
979 次查看
Nycil
Contributor I

Thanks a lot Kef. I typecasted the parameters of the functions that are being called and it solved the problem. The reason for the Error "_CONV_GLOBAL_TO_NEAR" was because I was giving a far pointer as a parameter to the function which accepted only near pointers.

 

Thanks. And Problem solved.

P.S. How do I put this discussion as solved?

0 项奖励
回复