2024-07-20 04:34 AM - last edited on 2024-07-22 04:06 AM by SofLit
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!
Solved! Go to Solution.
2024-07-22 04:02 AM
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 */
}
}
2024-07-20 07:04 AM
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.
2024-07-22 04:02 AM
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 */
}
}