Ian Massey

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

Discussion created by Ian Massey on Sep 4, 2008
Latest reply on Sep 4, 2008 by Steve Mcaslan
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    );
}
}
 

Outcomes