AnsweredAssumed Answered

LPC54608 can bus off and can bus disconnected detection

Question asked by cybaluke on Jul 13, 2018
Latest reply on Jul 19, 2018 by cybaluke

Hi, I'm working with CAN periph. on a LPC54608.

I started from the example code "mcan_interrupt_transfer" from SDK with the OM13092 evb, I use the TJA1050T external transceiver and my code seems to works right.

I'm using the callback function as in the example code:

static void mcan_callback(CAN_Type *base, mcan_handle_t *handle, status_t status, uint32_t result, void *userData)



and I use the

   MCAN_TransferSendNonBlocking(VSCP_MCAN, &mcanHandle, &txXfer);


   MCAN_TransferReceiveFifoNonBlocking(VSCP_MCAN, 0, &mcanHandle, &rxXfer);

functions to write to and read from CAN bus, tha code seems to work fine but now I need some help to solve 2 problems:

1 - how can I detect the BUS_OFF condition in the mcan_callback function?
2 - when there are NO nodes connected in the bus (i.e. when the tranceiver is not conneced on can bus)  the code hangs in the while loop after the MCAN_TransferSendNonBlocking waiting the write completion:


      MCAN_TransferSendNonBlocking(VSCP_MCAN, &mcanHandle, &txXfer);

      while (!txComplete){ }   //<--it hanhs here...

      ... do something...


How can I detect when the bus is not connected to the tranceiver or how can I detect an error on the tranceiver?


I tried to catch the kStatus_MCAN_UnHandled condition in the  mcan_callback function but it seems to be detected only when the tranceiver works right,  but if it doesn't work right (for example the termination is broken) the condition kStatus_MCAN_UnHandled  dosn't work...  Is it possible to set a timeout for the CAN controller?


thanks for any suggestion...