2021-01-11 07:12 AM
Hi all,
I have the problem concerning resetting the CAN bus after the other side was set to a wrong bitrate:
Example:
My system is sending data with 500 kBit. But the receiver is set to 1 MBit.
This results of course in Errors when sending data.
I handle this by resetting the CAN Bus port after a couple of Errors.
As soon as the receiver switches to the correct bitrate of 500 kBit, my system should then work properly, but it still gets Error Interrupts - even after another reset.
The debugger runs into "Error Warning" and "Error Passive" Interrupt states. And only a small part of the messages will be transmitted.
Sometimes it works as expected, but most times it is still getting Error Interrupts.
How can I safely return to a working CAN interface?
Here is what I do to reset the CAN Bus:
HAL_CAN_DeInit(&hcan1);
MX_CAN1_Init(); // Je nach Konfig aus SysInfo für Baudrate initialisieren
/* CAN1 init function */
void MX_CAN1_Init(void)
{
hcan1.pTxMsg = &CANTxMessage;
hcan1.pRxMsg = &CANRxMessage;
hcan1.Instance = CAN1;
hcan1.Init.Prescaler = 9;
hcan1.Init.Mode = CAN_MODE_NORMAL;
hcan1.Init.SJW = CAN_SJW_1TQ;
hcan1.Init.BS1 = CAN_BS1_3TQ;
hcan1.Init.BS2 = CAN_BS2_1TQ;
hcan1.Init.TTCM = DISABLE;
hcan1.Init.ABOM = ENABLE;
hcan1.Init.AWUM = DISABLE;
hcan1.Init.NART = DISABLE;
hcan1.Init.RFLM = DISABLE;
hcan1.Init.TXFP = DISABLE;
if (HAL_CAN_Init(&hcan1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
Solved! Go to Solution.
2024-05-16 06:06 AM - edited 2024-05-16 08:20 AM
That is what I am seeing in FDCAN. I came upon a site where the termination was incorrect and noticed a protoype device (STM32G474) did not timeout and reconnect/continue to RX frames.
I am used to the PIC18 "classic-mode-CAN" which will always have the error counters count back down and let the device try again. I shall perform some experiments and com up with a RESET FDCAN procedure that works for me.