2022-07-01 02:39 AM
Hi im trying to develop a bit of error management in my canbus driver.
I noticed there is an ErrorCode inside the canbus structure.
That error code could have any of these values:
But it turns out the hcan.ErrorCode is always HAL_CAN_ERROR_NONE, even if the canbus is not plugged to anything wich should give any of these:
//#define HAL_CAN_ERROR_EPV (0x00000002U) /*!< Error Passive */
//#define HAL_CAN_ERROR_BOF (0x00000004U) /*!< Bus-off error */
//#define HAL_CAN_ERROR_ACK (0x00000020U) /*!< Acknowledgment error */
Am i missing something out here? maybe something needs to be enabled somewhere in the HAL to get errors¿
Solved! Go to Solution.
2022-07-05 01:11 AM
This is not fixed yet:
What i ended up doing is my own thing ignoring the canbus error handler logic .
reseting the whole canbus peripheral when the mailboxes are full.
HAL_CAN_DeInit(_hcan);
HAL_CAN_Init(_hcan);
CanSETUPnoFilter(_hcan);
Because even if i "abort" the mailboxes the canbus TX is still jammed somehow.
HAL_CAN_AbortTxRequest(hcan_object_reference, CAN_TX_MAILBOX0+CAN_TX_MAILBOX1+CAN_TX_MAILBOX2);//empty all mailboxes
2022-07-01 02:43 AM
Maybe i need to implement the error callback myself??
void (* ErrorCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Error callback */
and make it modify the hcan struct.ErrorCode
2022-07-01 03:55 AM
https://community.st.com/s/question/0D50X00009XkWlmSAF/stm32cube-fwl4-v1110-bug-in-new-can-driver
This helps, maybe i need to ignore HAL and use CAN_TSR register directly
2022-07-05 01:11 AM
This is not fixed yet:
What i ended up doing is my own thing ignoring the canbus error handler logic .
reseting the whole canbus peripheral when the mailboxes are full.
HAL_CAN_DeInit(_hcan);
HAL_CAN_Init(_hcan);
CanSETUPnoFilter(_hcan);
Because even if i "abort" the mailboxes the canbus TX is still jammed somehow.
HAL_CAN_AbortTxRequest(hcan_object_reference, CAN_TX_MAILBOX0+CAN_TX_MAILBOX1+CAN_TX_MAILBOX2);//empty all mailboxes