I'm trying to run the sample code from document AN3034 "Using MSCAN on the HCS12 Family". The code is in document AN3034SW. Both of these documents are provided by NXP.
I did modify an include statement and the pragma Link_Info so that it matched the development board I am working with, the MC9S12DG256 development board.
I tried to compile the code and I am getting "Error C2801 ';' missing", but it seems like I have all of the appropriate semicolons. It is also strange because the error happens on 4 very similar lines of code. It is during the CANInit function that this occurs. The CANInit function is shown below. The full code is attached. The code that I copied and minimally modified is from AN3034SW. The lines causing errors are in RED. They all cause the same error: "Error C2801 ';' missing". I am using CodeWarrior 5.9.0.
//CANInit Function
void CANInit(void){
CAN0CTL0 = 0x01; //Enter initialization mode
while(!(CAN0CTL1&0x01)){}; //Wait for initialization mode ACK
CAN0CTL1 = 0xA0; //Enable MSCAN module and Loopback Mode
CAN0BTR0 = 0xC7; //Synch Jump = 3Tq clock cycles (re calculate?)
CAN0BTR1 = 0x3A; //Set number of samples per bit, TSEG1 and TSEG2
CAN0IDAC = 0x10; //set four 16-bit filters
//Acceptance Filters
CAN0IDAR0 = ACC_CODE_ID100_HIGH; //16-bit filter 0
CAN0IDMR0 = MASK_CODE_ST_ID_HIGH; //Accepts Standard Data Frame Msg ERROR Missing ;?
CAN0IDAR1 = ACC_CODE_ID100_LOW; //with ID 0x100
CAN0IDMR1 = MASK_CODE_ST_ID_LOW;
CAN0IDAC = 0x10; //Not sure why this is twice in code
CAN0IDAR2 = 0x00; //16-bit filter 1
CAN0IDMR2 = MASK_CODE_ST_ID_HIGH; //Accepts standard Data frame msg
CAN0IDAR3 = 0x00; //with ID 0x000
CAN0IDMR3 = MASK_CODE_ST_ID_LOW;
CAN0IDAR4 = 0x00; //16-bit filter 2
CAN0IDMR4 = MASK_CODE_ST_ID_HIGH; //Accepts standard Data frame msg
CAN0IDAR5 = 0x00; //with ID 0x000
CAN0IDMR5 = MASK_CODE_ST_ID_LOW;
CAN0IDAR6 = 0x00; //16-bit filter 3
CAN0IDMR6 = MASK_CODE_ST_ID_HIGH; //Accepts standard Data frame msg
CAN0IDAR7 = 0x00; //with ID 0x000
CAN0IDMR7 = MASK_CODE_ST_ID_LOW;
CAN0CTL0 = 0x00; //Exit initialization mode request
while((CAN0CTL1&0x01)!=0){}; //Wait for normal mode
} //end void CANInit
Original Attachment has been moved to: main.c.zip
Hello Rachel,
I have checked your file , there is some spelling error for macro definition .
I changed them , please check the attachment .
Hope it helps
Have a great day,
Alice
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------