Skip to main content
Associate
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. 

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ƎALLEm
mƎALLEmBest answer
Technical Moderator
March 6, 2024

Hello,

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

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
AeroiivAuthor
Associate
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?

mƎALLEm
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();

 

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."