#define register

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

#define register

Jump to solution
5,446 Views
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
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,614 Views
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.

View solution in original post

0 Kudos
Reply
3 Replies
1,615 Views
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 Kudos
Reply
1,614 Views
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 Kudos
Reply
1,614 Views
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 Kudos
Reply