cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32G0b FDCAN automatic bus-off management

GilAndrei
Associate

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!

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

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 */
  }
}
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.

View solution in original post

2 REPLIES 2
MHoll.2
Senior

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

 

SofLit
ST Employee

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 */
  }
}
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.