Skip to main content
GEsch.1
Associate
December 14, 2020
Solved

HAL_CAN_Init returning an error

  • December 14, 2020
  • 3 replies
  • 1180 views

I'm getting started with the CAN controller on the STM32F105. One of the first issues I'm running into is that the HAL_CAN_Init() function returns an error. It seems to time out while waiting for CAN_MSR_SLAK to be cleared. Where can I find more information about this?

Note:

  • I have connected a CAN transceiver to the corresponding ports but there is no traffic on the bus yet. CAN RX is pulled high at 3.3 V.
  • Putting the CAN controller into loopback mode makes no difference
This topic has been closed for replies.
Best answer by GEsch.1

Thanks Bouraoui. It turns out that the CAN RX and TX ports were mapped to the wrong GPIOs.

Regards,

Guy.

3 replies

Bowman32
ST Employee
December 14, 2020

Hi @GEsch.1​ 

To be sure regarding GPIO configuration, peripherals clock gating... You can refer to CAN example available on STM32CubeF1 firmware package via this path STM32Cube_FW_F1_V1.8.0\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking

Bouraoui

GEsch.1
GEsch.1AuthorBest answer
Associate
December 16, 2020

Thanks Bouraoui. It turns out that the CAN RX and TX ports were mapped to the wrong GPIOs.

Regards,

Guy.

Uwe Bonnes
Chief
December 14, 2020

To my knowledge, Can init needs an ack from another device on the bus to succeed.