cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F042K6 GPIO Initialization Error

Tannenbaum
Associate

Hi there,

currently I am trying to set up the CAN peripheral on the STM32F042K6 and it is getting stuck while initializing the according GPIOs. The CPU gets stuck at the HAL_GPIO_Init line, I am not able to connect with an ST Link without connecting under hardware reset and the system is not going into the Error_Handler.

  GPIO_InitStruct.Pin = GPIO_PIN_12;
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  GPIO_InitStruct.Alternate = GPIO_AF4_CAN;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

While the GPIO_PIN_11 is the CAN RX pin and can be initialized flawlessly. GPIO_PIN_12 is the CAN TX pin and it is not working. I have not experienced something like this while working with any STM32 product.

Here some infos about my code gernation:

Code generated with CubeMX 5.4.0

Firmware package used: F0_V1.11.0

I really hope there is someone able to help me.

Best whishes

Tristan

1 REPLY 1

> The CPU gets stuck at the HAL_GPIO_Init line,

Make sure there's no hardware issue with the pin - shorts, or a connected device which potentially shorts the power supply momentarily.

JW

PS. Change your username to a normal nick.