Skip to main content
GEsch.1
Associate
Dec 14, 2020 2:37 PM UTC
Solved

HAL_CAN_Init returning an error

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.
GEsch.1
GEsch.1Best answer
Associate
Dec 16, 2020 1:24 PM UTC

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
Dec 14, 2020 3:47 PM UTC

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
Dec 16, 2020 1:24 PM UTC

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

Regards,

Guy.

Uwe Bonnes
Chief
Dec 14, 2020 6:32 PM UTC

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