Skip to main content
Visitor II
March 6, 2024
Solved

FD_CAN How to reset error counter

  • March 6, 2024
  • 1 reply
  • 2660 views

In the FD_CAN register, there is a CEL[7:0]:, REC[6:0]: and TEC[7:0]:,

The CEL register is not being reset on read and goes into the Bus-Off mode.

Do I need to also reset the REC and TEC register?

I am currently using the HAL_GetErrorCounter() function to read the register. 

    This topic has been closed for replies.
    Best answer by mƎALLEm

    Hello,

    You need to reset the FDCAN peripheral to reset REC[6:0] and TEC[7:0].

    1 reply

    mƎALLEmAnswer
    Technical Moderator
    March 6, 2024

    Hello,

    You need to reset the FDCAN peripheral to reset REC[6:0] and TEC[7:0].

    AeroiivAuthor
    Visitor II
    March 6, 2024

    In order to reset the FDCAN peripheral without power cycling the system;

    I am currently calling 

    HAL_StatusTypeDef HAL_FDCAN_DeInit(FDCAN_HandleTypeDef *hfdcan)

    and the reinitializing using 

    static void MX_FDCAN1_Init(void)

     

    Are there anything else specific that needs to happen, within the DeInit function it only seems to disable the interrupt line CLEAR_BIT(hfdcan->Instance->ILE, (FDCAN_INTERRUPT_LINE0 | FDCAN_INTERRUPT_LINE1));

    Do I also need to deinitlize the clock as well?

    Technical Moderator
    March 7, 2024

    Hello,

    You need to reset FDCAN peripheral by RCC in HAL_FDCAN_MspDeInit(): 

    __HAL_RCC_FDCAN_FORCE_RESET();
    __HAL_RCC_FDCAN_RELEASE_RESET();