cancel
Showing results for 
Search instead for 
Did you mean: 

CAN_Error_Code doesnt really do anyting? (stm32f0xx)

Javier1
Principal

Hi im trying to develop a bit of error management in my canbus driver.

I noticed there is an ErrorCode inside the canbus structure.

0693W00000QKGYhQAP.png 

That error code could have any of these values:

0693W00000QKGaEQAX.png 

 

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¿

we dont need to firmware by ourselves, lets talk
1 ACCEPTED SOLUTION

Accepted Solutions
Javier1
Principal

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

we dont need to firmware by ourselves, lets talk

View solution in original post

3 REPLIES 3
Javier1
Principal

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

we dont need to firmware by ourselves, lets talk
Javier1
Principal

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

we dont need to firmware by ourselves, lets talk
Javier1
Principal

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

we dont need to firmware by ourselves, lets talk