Skip to main content
LSant.7
Associate
May 8, 2023
Solved

Why SMT32L031x UART pins do not work?

  • May 8, 2023
  • 3 replies
  • 1036 views

Hello, I have a custom board with a SMT32L031F6P6 on it: PA2 and PA3 USART2 channel seems not to work even if they are correctly set in the .ioc file.

I have tried the same code on the NUCLEO-L031K6 board using VCP-TX and VCP-RX (PA2 e PA15) default pins and it works correctly, but if I move the UART pins to the Arduino-compatible ones, PA9 and PA10, it dosen't work anymore.

What am I doing wrong? The UM1956 says that "Only one USART is available and it is shared between Arduino Nano and VCP. The selection is done by remapping (no hardware configuration to change)." but I think something is missing.

This is the working code, in CubeIDE v.11.0:

...
#ifdef __GNUC__
/* With GCC, small printf (option LD Linker->Libraries->Small printf
 set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
...
int main(void)
{
 HAL_Init();
 SystemClock_Config();
 MX_GPIO_Init();
 MX_USART2_UART_Init();
 
 while (1)
 { 
 printf("hello\r\n");
	 HAL_Delay(500);
 }
}
 
...
 
static void MX_USART2_UART_Init(void)
{
 huart2.Instance = USART2;
 huart2.Init.BaudRate = 115200;
 huart2.Init.WordLength = UART_WORDLENGTH_8B;
 huart2.Init.StopBits = UART_STOPBITS_1;
 huart2.Init.Parity = UART_PARITY_NONE;
 huart2.Init.Mode = UART_MODE_TX_RX;
 huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
 huart2.Init.OverSampling = UART_OVERSAMPLING_16;
 huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
 huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
 if (HAL_UART_Init(&huart2) != HAL_OK)
 {
 Error_Handler();
 }
}
 
...
 
PUTCHAR_PROTOTYPE
{
 /* Place your implementation of fputc here */
 /* e.g. write a character to the USART2 and Loop until the end of transmission */
 HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, 0xFFFF);
 
 return ch;
}

This topic has been closed for replies.
Best answer by LSant.7

sorry, this question was useless, I fix the problem just resoldering the mcu. Is it possible to delete it?

3 replies

waclawek.jan
Super User
May 8, 2023

> PA2 and PA3 (Arduino Nano-compatible pins) USART2 channel seems not to work

> [...]

> if I move the UART pins to the Arduino-compatible ones, PA9 and PA10, it dosen't work anymore.

So, which pair is it: PA2/PA3, or PA9/PA10?

Read out content of UART and relevant GPIO, and check/post/compare to working case.

JW

Karl Yamashita
Lead III
May 9, 2023

Upload the ioc file so we can see how you configured it

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
LSant.7
LSant.7AuthorBest answer
Associate
May 10, 2023

sorry, this question was useless, I fix the problem just resoldering the mcu. Is it possible to delete it?