cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F105 can stop working after error

sifourquier
Associate

Hello

I have a code use CAN2 on a stm32F105 he work fine if the CAN bus have not disturbance

But if i have to many disturbance for exemple if i make a short circuit bethen CANH and CANL when i remove the short circuit the CAN no restart to send data. I need stop and restart CAN  

HAL_CAN_Stop(&hcan2);

HAL_CAN_Start(&hcan2);

Then he work but i lose data during this time

 

during bug 

HAL_CAN_GetTxMailboxesFreeLevel(&hcan2) return 0

hcan2.ErrorCode are equal to 0

hcan2.Instance->TSR -> have the bit CAN_TSR_TERR0 set to 1 but if i call HAL_CAN_AbortTxRequest(&hcan2,CAN_TX_MAILBOX0);

CAN_TSR_TERR0 return to 0 but CAN no restart


Can you help me for have a CAN work every time?

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

You need to enable the automatic bus off management by Hardware: .Init.AutoBusOff= ENABLE

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

1 REPLY 1
SofLit
ST Employee

Hello,

You need to enable the automatic bus off management by Hardware: .Init.AutoBusOff= ENABLE

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.