Far pointer problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
1,971件の閲覧回数
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,305件の閲覧回数
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,306件の閲覧回数
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,305件の閲覧回数
foo222
Contributor II

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

0 件の賞賛
返信