cancel
Showing results for 
Search instead for 
Did you mean: 

FD_CAN How to reset error counter

Aeroiiv
Associate II

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

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.
PS: Be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help/support.

View solution in original post

5 REPLIES 5
SofLit
ST Employee

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.
PS: Be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help/support.

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?

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.
PS: Be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help/support.

Is there a difference between using

__HAL_RCC_FDCAN_FORCE_RESET();
__HAL_RCC_FDCAN_RELEASE_RESET();

and using  __HAL_RCC_FDCAN_CLK_DISABLE();

 

In my version of MspDeInit it uses the rather method instead of the force_reset/release_reset.

void HAL_FDCAN_MspDeInit(FDCAN_HandleTypeDef* hfdcan)
{
if(hfdcan->Instance==FDCAN1)
{
/* USER CODE BEGIN FDCAN1_MspDeInit 0 */

/* USER CODE END FDCAN1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_FDCAN_CLK_DISABLE();

/**FDCAN1 GPIO Configuration
PB12 ------> FDCAN1_RX
PB13 ------> FDCAN1_TX
*/
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_12|GPIO_PIN_13);

/* USER CODE BEGIN FDCAN1_MspDeInit 1 */

/* USER CODE END FDCAN1_MspDeInit 1 */
}

}

 __HAL_RCC_FDCAN_CLK_DISABLE only de-asserts the clock to the peripheral and as soon as you enable it again  the registers content are kept while you're looking for a reset of the registers which can be done by:

__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.
PS: Be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help/support.