FlexCAN bus error handling?

cancel
Showing results for 
Search instead for 
Did you mean: 

FlexCAN bus error handling?

745 Views
lawsonbob
Contributor I

Are there any examples for S32 Design Studio for handling CAN bus errors using the FlexCAN driver? Our application needs to actively monitor bus warn, passive and bus off conditions. In the case of a bus off condition, we need to periodically reinitialize the FlexCAN hardware.

In flexcan_irq.c, I see that all CAN related interrupts are forwarded to the same interrupt handler:

/* Implementation of CAN0 IRQ handler for OR'ed interrupts (Bus Off,
Transmit Warning, Receive Warning). */
void CAN0_ORed_IRQHandler(void)
{
    FLEXCAN_IRQHandler(0U);
}

/* Implementation of CAN0 IRQ handler for interrupts indicating that errors were
detected on the CAN bus. */
void CAN0_Error_IRQHandler(void)
{
    FLEXCAN_IRQHandler(0U);
}

In FLEXCAN_IRQHandler() in flexcan_driver.c, the interrupt handler processes all normal transmit and receive interrupts then at the bottom of the handler calls:

/* Clear all other interrupts in ERRSTAT register (Error, Busoff, Wakeup) */
FLEXCAN_ClearErrIntStatusFlag(base);

In FLEXCAN_ClearErrIntStatusFlag() in flexcan_hw_access.c, the error interrupt bits are simply cleared with no way of reporting any error status up to the application:

void FLEXCAN_ClearErrIntStatusFlag(CAN_Type * base)
{
    if((base->ESR1 & FLEXCAN_ALL_INT) != 0U)
    {
        (base->ESR1) = FLEXCAN_ALL_INT;
#ifdef ERRATA_E9005
        /* Dummy read as a workaround for errata e9005 to ensure the flags are
        cleared before continuing. */
        (void)(base->ESR1);
#endif
    }
}

Am I missing something? This is my first experience with the FlexCAN driver but at first glance it appears that it has no support at all for CAN bus error detection / recovery.

0 Kudos
2 Replies

198 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

what is your S32DS version and which SDK you are using? 

Jiri

0 Kudos

198 Views
lawsonbob
Contributor I

S32 Design Studio for ARM, v2018.R1.180326

S32K146 SDK v0.8.6

0 Kudos