Skip to main content
Associate
January 8, 2024
Solved

STM32F105 can stop working after error

  • January 8, 2024
  • 1 reply
  • 949 views

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?

This topic has been closed for replies.
Best answer by mƎALLEm

Hello,

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

1 reply

mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
January 9, 2024

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 "Best answer" on the reply which solved your issue or answered your question.