Showing results for 
Search instead for 
Did you mean: 

CAN Initialization failure then success

Associate II


I have an interesting situation. When I start my app on the F303RE Nucleo I initialize all the peripherals. When CAN is initialized it returns a HAL_TIMEOUT error. If I call the same initialization code a second time it initialized correctly with no error and the CAN bus works correctly. It is not timing related as I can postpone the first init and it always fails.

The code works fine after the second init so this isn’t a big deal but I was wondering if anyone else has experienced this and can explain the first failure.


  • Dave

ST Employee

Hello @DPeki.1​,

Which mode are you using? Are you using transceiver?

Try to use LOOPBACK mode in order to run and test the functions.


When your question is answered, please close this topic by clicking "Accept as Solution".
Associate II

Hello Imen,

I'm not sure what you mean by mode. Yes, I have a transceiver (max13053a).

As I said the CAN bus is working fine after the SECOND initialization. I don't think LOOPBACK will help me since, I assume, that LOOPBACK won't work if initialization fails and after the second initialization everything works fine...

I'm now simply initializing the system twice and operation continues fine after that. It's just one of those anomalies that I wonder about.


  • Dave

Do you have two nodes on your CAN bus? If your node is the first to initialize it won't see another node and will fail. If there's enough time for the remote to start, then your second try might succeed. One of the more difficult tasks with ST's version of CAN is synchronizing the initial net startup of the first two nodes.

Look at the CAN status and error registers after the first fail. It will tell you why the timeout occurred. If you don't handle the CAN interrupt for errors, then you will have a very difficult time getting CAN to work reliably. Errors do occur as part of normal operations.

Jack Peacock