Skip to main content
Visitor II
July 20, 2024
Solved

Stm32G0b FDCAN automatic bus-off management

  • July 20, 2024
  • 2 replies
  • 1802 views

I decided to replace the STM32F105 with the STM32G0B in my project.
I have problems setting up FDcan.
The STM32F105 had an “automatic bus-off management” setting, but the STM32G0B does not! This feature is enabled by default, how can I disable it? So that when Can-bus has errors, it doesn’t stop!

Best answer by mƎALLEm

Hello;

Not sure what do you mean by this:

"but the STM32G0B does not! This feature is enabled by default, how can I disable it?" But in FDCAN peripheral there is no automatic bus off management, so how you tell that it's enabled by default.

As stated by @MHoll.2, the conditions to recover from Bus-off are described in the reference manual.

In fact to recover from bus off state you need to do it by software:

Example:

Activate Bus-Off interrupt:

HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_BUS_OFF, 0);

In the call back, recover from bus-off state by software:


void HAL_FDCAN_ErrorStatusCallback(FDCAN_HandleTypeDef *hfdcan, uint32_t ErrorStatusITs)
{
 if((ErrorStatusITs & FDCAN_IE_BOE) != 0) /* If Bus-Off error occured */
 {
 hfdcan->Instance->CCCR &= ~FDCAN_CCCR_INIT; /* Recover from Bus-Off */
 }
}

2 replies

MHoll.2
Senior III
July 20, 2024

Hi,

BusOff is a state requested by the CAN-Bus standard ISO11898-1.

In RM0444 on page 1238 You finde how to handle BusOff on the FDCAN Controller.

MHoll2_0-1721484199589.png

 

mƎALLEm
mƎALLEmBest answer
Technical Moderator
July 22, 2024

Hello;

Not sure what do you mean by this:

"but the STM32G0B does not! This feature is enabled by default, how can I disable it?" But in FDCAN peripheral there is no automatic bus off management, so how you tell that it's enabled by default.

As stated by @MHoll.2, the conditions to recover from Bus-off are described in the reference manual.

In fact to recover from bus off state you need to do it by software:

Example:

Activate Bus-Off interrupt:

HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_BUS_OFF, 0);

In the call back, recover from bus-off state by software:


void HAL_FDCAN_ErrorStatusCallback(FDCAN_HandleTypeDef *hfdcan, uint32_t ErrorStatusITs)
{
 if((ErrorStatusITs & FDCAN_IE_BOE) != 0) /* If Bus-Off error occured */
 {
 hfdcan->Instance->CCCR &= ~FDCAN_CCCR_INIT; /* Recover from Bus-Off */
 }
}