Sven Krege

Problems with Port definition...CAN Module...Cosmic Compiler

Discussion created by Sven Krege on Jan 21, 2009
Latest reply on Feb 27, 2009 by Sven Krege
hello,

I just write a function for initialization of the CAN modules of a HCS12 using cosmic compiler version 4.4.6. Now I have the following problem. I pass the number of the CAN module which should be initialized to a function. The number of the CAN module is stored in the variable CANm;
I defined CAN0 in iosdp256.h:
Code:
#define CAN0 0x0140;
Then I defined the following in iosdp256.h:
Code:
#define CANCTL0   0X00   
#define CANCTL1   0X01                            
#define CANBTR0   0X02                         
#define CANBTR1   0X03                         
#define CANRFLG   0X04                          #define CANRIER   0X05           #define CANTFLG   0X06                          #define CANTIER   0X07        #define CANTBSEL  0X0A         
#define CANIDAC   0x0B        
#define CANIDAR0  0x10    #define CANIDAR1  0x11    #define CANIDAR2  0x12    #define CANIDAR3  0x13    #define CANIDMR0  0x14    #define CANIDMR1  0x15    #define CANIDMR2  0x16    #define CANIDMR3  0x17    #define CANIDAR4  0x18    #define CANIDAR5  0x19    #define CANIDAR6  0x1A    #define CANIDAR7  0x1B    #define CANIDMR4  0x1C    #define CANIDMR5  0x1D    #define CANIDMR6  0x1E    #define CANIDMR7  0x1F

 I want to call a function like

Code:
CANInit(CAN0);

 To enable the CAN module CAN0 I wanted to use
Code:
_IO(CANm + CANCTL1) |= 0x80;

 because in iosdp256.h is defined

Code:
#ifndef _BASE#define _BASE 0#endif#define _IO(x) @(_BASE)+(x)

But I always get the error message "bad space modifier" and "invalid lvalue" for the lines with  _IO(.......)|=... .

Here once again more clear:
Code:
#include <iosdp256.h>                   /* contains register definitions */
                                        /* for the 9S12DP256             */
void CANInit(unsigend char CANm)
{
    _IO(CANModule + CANCTL0) |= 0x01;    // Enter Initialization-Mode
    _IO(CANm + CANCTL1) |= 0x80;         // Enable CAN module CAN0
}

CANInit(CAN0);


Could someone tell me what is wrong or how I can solve the problem?

Best regards

Outcomes