Far pointer problem

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

Far pointer problem

跳至解决方案
1,974 次查看
foo222
Contributor II

Hi all,

 

I'm trying to write a simple ROM CRC routine, but for some reason I'm only able to access up to 16 bit memory addresses.

 

unsigned long* _far     temp_address;

unsigned long              value;

 

temp_address = (unsigned long* _far) 0x088000;

 

value = *(temp_address);

 

temp_address is correctly set, however when I attempt to read the value at that address, I'm getting the value from address 0x8000.   Any suggestions are appreciated.

 

MC9S12P128

CodeWarrior Version 5.9

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,308 次查看
CrasyCat
Specialist III
  1. Hello

 

Compiler is using run time library call _LOAD_FAR_16 to load data from banked memory,

For this to work:

  1- Make sure to link your application with datapage.c

  2- Make sure to place the section NON_BANKED in non banked memory in your .prm file.

 

For HCS12P family microcontrollers, you need to update datapage.c to specify the appropriate PPAGE register (0x15)

This is done as follows in datapage.c:

/* Compile with option -DHCS12 to activate this code */#if defined(HCS12) || defined(_HCS12) || defined(__HCS12__) /* HCS12 family has PPAGE register only at 0x30 */#if defined (HCS12P) /* HC912P128, HCS12P96, HCS12P64, HCS12P32 derivative has PPAGE register only at 0x15 */#define PPAGE_ADDR (0x15+REGISTER_BASE)#else#define PPAGE_ADDR (0x30+REGISTER_BASE)#endif#ifndef __PPAGE__ /* may be set already by option -CPPPAGE */#define __PPAGE__#endif/* Compile with option -DDG128 to activate this code */#elif defined DG128 /* HC912DG128 derivative has PPAGE register only at 0xFF */#define PPAGE_ADDR (0xFF+REGISTER_BASE)#ifndef __PPAGE__ /* may be set already by option -CPPPAGE */#define __PPAGE__#endif#elif defined(HC812A4)/* all setting default to A4 already */#endif

 

 

Make sure to add the option -DHCS12P when building your project.

 

CrasyCat

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,309 次查看
CrasyCat
Specialist III
  1. Hello

 

Compiler is using run time library call _LOAD_FAR_16 to load data from banked memory,

For this to work:

  1- Make sure to link your application with datapage.c

  2- Make sure to place the section NON_BANKED in non banked memory in your .prm file.

 

For HCS12P family microcontrollers, you need to update datapage.c to specify the appropriate PPAGE register (0x15)

This is done as follows in datapage.c:

/* Compile with option -DHCS12 to activate this code */#if defined(HCS12) || defined(_HCS12) || defined(__HCS12__) /* HCS12 family has PPAGE register only at 0x30 */#if defined (HCS12P) /* HC912P128, HCS12P96, HCS12P64, HCS12P32 derivative has PPAGE register only at 0x15 */#define PPAGE_ADDR (0x15+REGISTER_BASE)#else#define PPAGE_ADDR (0x30+REGISTER_BASE)#endif#ifndef __PPAGE__ /* may be set already by option -CPPPAGE */#define __PPAGE__#endif/* Compile with option -DDG128 to activate this code */#elif defined DG128 /* HC912DG128 derivative has PPAGE register only at 0xFF */#define PPAGE_ADDR (0xFF+REGISTER_BASE)#ifndef __PPAGE__ /* may be set already by option -CPPPAGE */#define __PPAGE__#endif#elif defined(HC812A4)/* all setting default to A4 already */#endif

 

 

Make sure to add the option -DHCS12P when building your project.

 

CrasyCat

0 项奖励
回复
1,308 次查看
foo222
Contributor II

Yes, that did it, thanks very much for your help, it is appreciated!!

0 项奖励
回复