Hi,   I am implementing a CAN controller on the HCS12X us...

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

Hi,   I am implementing a CAN controller on the HCS12X us...

1,421 Views
IanM
Contributor I
Hi,
 
I am implementing a CAN controller on the HCS12X using the x-gate based on AN2726, I have got the X-Gate to interrupt and handle an Rx CAN message no problem and create an event in the core micro once completed using the sif() instruction.  The issue that I am have is that when I try to update a variable that has been passed to the x-gate Rx Can handler I get a XGateError Interrupt raised.  As far as I can tell I have followed the application note but stil get this error, I have no problem reading the CAN registers in the Xgate interrupt handler, I am using the COSMIC compiler.
 
Example code below any help would be appreciated.
 
 
XGCANstruct XGCAN0 = {&CAN0
                     ,ID_Table_CAN0  
                     ,MsgData_CAN0
                     ,MsgLen_CAN0
                     ,MsgStatus 
           ,MsgIndex_CAN0};
 
@interrupt void Xgate_CAN_Receive(XGCANstruct channel)
{
 tU08 box;
 tU08 rxid;
 if(_ssem(CANSEMXG))
 { 
          _csem(CANSEMXG);
  
 //This line causes the error 
  *(tU16*)(channel.pBuffer[0]    ) = *(tU16*)(channel.pCAN->rxbuf.dsr    );
}
}
 
Labels (1)
0 Kudos
1 Reply

565 Views
Steve
NXP Employee
NXP Employee
It depends a bit on the S12X that you are using but have a look at AN3555 for some help on how to track down errors.
I would guess that you are probably trying to do a misaligned access when reading the variable
0 Kudos