2022-11-10 08:26 AM
Hello,
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.
Thanks
2022-11-14 12:51 AM
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.
Imen
2022-11-14 08:16 AM
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.
Thanks,
2022-11-14 07:54 PM
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