Addressing NV_FTRIM in C for KA2

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

Addressing NV_FTRIM in C for KA2

跳至解决方案
5,427 次查看
CarlFST60L_3rd
Contributor I
Simple question, (not sure if this is in the correct section either, as i dont know what I am doing wrong)

using KA2 for a basic transmitter, written in C.

I want to load the trim, but, i get the warningC2705, and, it my problem is causing the wrong address to be loaded

Here is the code that i thought would simply load the trim from flash and store in RAM

  if((NV_ICSTRM_TRIM == 0xFF) | (NV_ICSTRM_TRIM == 0x00))
    ICSTRM = 0x80;
  else
    ICSTRM = NV_ICSTRM;
 
  if(NV_FTRIM_FTRIM)
    ICSSC_FTRIM = 1;
  else
    ICSSC_FTRIM = 0;

What is the correct method for loading testing/loading NV_ICSTRM_TRIM and ICSSC_FTRIM?

To save looking up the header file:
/*** ICSSC - ICS Status and Control; 0x00000017 ***/
typedef union {
  byte Byte;
  struct {
    byte FTRIM       :1;                                       /* ICS Fine Trim */
    byte             :1;
    byte CLKST       :1;                                       /* Clock Mode Status */
    byte             :1;
    byte             :1;
    byte             :1;
    byte             :1;
    byte             :1;
  } Bits;
} ICSSCSTR;
extern volatile ICSSCSTR _ICSSC @0x00000017;
#define ICSSC                           _ICSSC.Byte
#define ICSSC_FTRIM                     _ICSSC.Bits.FTRIM
#define ICSSC_CLKST                     _ICSSC.Bits.CLKST

#define ICSSC_FTRIM_MASK                1
#define ICSSC_CLKST_MASK                4


/*** NV_ICSTRM - Nonvolatile ICS Trim Register; 0x00003FFA ***/
typedef union {
  byte Byte;
  struct {
    byte TRIM        :8;                                       /* ICS Trim Setting */
  } Bits;
} NV_ICSTRMSTR;
/* Tip for register initialization in the user code:  const byte NV_ICSTRM_INIT @0x00003FFA = <NV_ICSTRM_INITVAL>; */
#define _NV_ICSTRM (*(const NV_ICSTRMSTR *)0x00003FFA)
#define NV_ICSTRM                       _NV_ICSTRM.Byte
#define NV_ICSTRM_TRIM                  _NV_ICSTRM.Bits.TRIM

#define NV_ICSTRM_TRIM_MASK             255
#define NV_ICSTRM_TRIM_BITNUM           0


/*** NV_FTRIM - Nonvolatile ICS Fine Trim Register; 0x00003FFB ***/
typedef union {
  byte Byte;
  struct {
    byte FTRIM       :1;                                       /* ICS Fine Trim */
    byte             :1;
    byte             :1;
    byte             :1;
    byte             :1;
    byte             :1;
    byte             :1;
    byte             :1;
  } Bits;
} NV_FTRIMSTR;
/* Tip for register initialization in the user code:  const byte NV_FTRIM_INIT @0x00003FFB = <NV_FTRIM_INITVAL>; */
#define _NV_FTRIM (*(const NV_FTRIMSTR *)0x00003FFB)
#define NV_FTRIM                        _NV_FTRIM.Byte
#define NV_FTRIM_FTRIM                  _NV_FTRIM.Bits.FTRIM

#define NV_FTRIM_FTRIM_MASK             1



Message Edited by CarlFST60L_3rd on 2007-09-30 01:55 PM
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,059 次查看
CompilerGuru
NXP Employee
NXP Employee
That particular problem has been fixed in the RS08 header files since the HC08 V6.0 release, I've attached the current ones for the KA2.

Daniel

Note: I did not actually test them, just shortly looked that they do indeed address this problem.

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,059 次查看
CarlFST60L_3rd
Contributor I
please excuse my gramma, must learn to read before pressing submit.

This is what i have done to solve my problem

volatile byte __far NV_ICSTRM_FAR @0x00003FFA;               //Added
volatile byte __far NV_FTRIM_FTRIM_FAR @0x00003FFB;    //Added

I am still interested in how to use the supplied header file to address these two varibles correctly.



Message Edited by CarlFST60L_3rd on 2007-10-01 03:10 AM
0 项奖励
回复
1,060 次查看
CompilerGuru
NXP Employee
NXP Employee
That particular problem has been fixed in the RS08 header files since the HC08 V6.0 release, I've attached the current ones for the KA2.

Daniel

Note: I did not actually test them, just shortly looked that they do indeed address this problem.

0 项奖励
回复
1,059 次查看
CarlFST60L_3rd
Contributor I
Thanks!
0 项奖励
回复