[code]
void ISRname (void) interrupt 19
{
status = CAN0STA;
if ((status&0x10) != 0)
{ // RxOk is set, interrupt caused by reception
CAN0STA = (CAN0STA&0xEF)|0x07; // Reset RxOk, set LEC to NoChange
/* read message number from CAN INTREG */
receive_data (0x01); // Up to now, we have only one RX message
}
if ((status&0x08) != 0)
{ // TxOk is set, interrupt caused by transmision
CAN0STA = (CAN0STA&0xF7)|0x07; // Reset TxOk, set LEC to NoChange
}
if (((status&0x07) != 0)&&((status&0x07) != 7))
{ // Error interrupt, LEC changed
/* error handling ? */
CAN0STA = CAN0STA|0x07; // Set LEC to NoChange
}
}
[code]