Skip to main content
tpeng.1
Associate III
April 11, 2023
Solved

Failure when Configuring UART2 in the STM32C031C6

  • April 11, 2023
  • 2 replies
  • 1115 views

When configuring UART2 in the STM32C0316-DK, the emulator is locked.

Error in executing 'step' command ... 

Target is not responding, retrying...

Code is running here (stm32c0xx_hal_msp.c line 272):

  /**USART2 GPIO Configuration

  PA8   ------> USART2_TX

  PA13   ------> USART2_RX

  */

  GPIO_InitStruct.Pin = GPIO_PIN_8;

  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

  GPIO_InitStruct.Alternate = GPIO_AF1_USART2;

  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  GPIO_InitStruct.Pin = GPIO_PIN_13;

  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

  GPIO_InitStruct.Alternate = GPIO_AF4_USART2;

  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

Need you help.

Tim

This topic has been closed for replies.
Best answer by Jaroslav JANOS

Hello @tpeng.1​ ,

this is quite common mistake, you reconfigured one of your pins used for debug (PA13). You should use other pins for the USART2, when you want to use SWD.

BR,

Jaroslav

2 replies

Jaroslav JANOS
Jaroslav JANOSBest answer
ST Employee
April 11, 2023

Hello @tpeng.1​ ,

this is quite common mistake, you reconfigured one of your pins used for debug (PA13). You should use other pins for the USART2, when you want to use SWD.

BR,

Jaroslav

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
tpeng.1
tpeng.1Author
Associate III
April 11, 2023
Hi Jaroslav,
Thank you very much for your quick response!
Now I understand that PA13 is used for debug.
Br,
Tim