cancel
Showing results for 
Search instead for 
Did you mean: 

Failure when Configuring UART2 in the STM32C031C6

tpeng.1
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
Jaroslav JANOS
ST Employee

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.

View solution in original post

2 REPLIES 2
Jaroslav JANOS
ST Employee

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.

Hi Jaroslav,
Thank you very much for your quick response!
Now I understand that PA13 is used for debug.
Br,
Tim