2024-03-06 09:15 AM
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.
Solved! Go to Solution.
2024-03-06 09:23 AM
Hello,
You need to reset the FDCAN peripheral to reset REC[6:0] and TEC[7:0].
2024-03-06 09:23 AM
Hello,
You need to reset the FDCAN peripheral to reset REC[6:0] and TEC[7:0].
2024-03-06 10:58 AM
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?
2024-03-07 12:15 AM
Hello,
You need to reset FDCAN peripheral by RCC in HAL_FDCAN_MspDeInit():
__HAL_RCC_FDCAN_FORCE_RESET();
__HAL_RCC_FDCAN_RELEASE_RESET();
2024-03-07 08:00 AM
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 */
}
}
2024-03-07 09:05 AM
__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();