#define register

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
5,050件の閲覧回数
elee40
Contributor I
I am using a freescale hc12 with codewarrior and trying to use a #define to refer to a memory register but continue to receive an error.  The error I get is
C2450: Expected ~ (IDENT auto const extern register static typedef volatile__interrupt friend inline operator virtual) .  I realize that these definitions are already in the header files....But for educational purposes I am trying to define my own references to the memory registers. Any help or suggestions would be much appreciated.
 
#include <hidef.h>      /* common defines and macros */
#include <mc9s12dt256.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dt256b"
#define EPCNT 0x000000AC
EPCNT = 0; 
 
  Thanks
        Erik
ラベル(1)
タグ(1)
0 件の賞賛
1 解決策
1,218件の閲覧回数
joeservo
Contributor III
try something like this:
 
#define PORTA    (*((volatile unsigned char*) (0x0000)))
 
what you are doing is only defining the number to a word.
 
you will probably get a link error about duplicate register names.  i usually change that to a warning and ignore.

元の投稿で解決策を見る

0 件の賞賛
3 返答(返信)
1,219件の閲覧回数
joeservo
Contributor III
try something like this:
 
#define PORTA    (*((volatile unsigned char*) (0x0000)))
 
what you are doing is only defining the number to a word.
 
you will probably get a link error about duplicate register names.  i usually change that to a warning and ignore.
0 件の賞賛
1,218件の閲覧回数
elee40
Contributor I
Still getting error C2450: Expected: ~ (IDENT operator .  Also getting error C1067: Object is missing decl specifiers.  I looked at the help under these errors, but as I am not the greatest programmer the explanation was not clear. 
 
#include <hidef.h>      /* common defines and macros */
#include <mc9s12dt256.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dt256b"
#define EPWM (*((volatile unsigned char*) (0x000000AC)))
EPWM = 0;
 
Erik
0 件の賞賛
1,218件の閲覧回数
elee40
Contributor I
Ignore my previous message.  It works as long as I assign a value to the memory register inside of main().  Thanks again.  Erik
0 件の賞賛