0

I'm trying to use the UART3 in NUCLEO-F746ZG with TrueStudio. USART3 connected to ST-LINK to support the virtual COM port, but it didn't work now. I don't have oscilloscope and I really want to see the print message through hyper terminal like a realterm.

I searched this issue and found that many users were having a hard time.

Finally, I found the solution for UART example which is in STM32CubMX from the following web site. If I copy the syscall.c, then it works fine in UART example.

https://community.st.com/s/question/0D50X00009XkXDcSAN/problem-with-uart-example-on-nucleof746zg

The following is UART example code from STM32CubeMX. Directory : STM32Cube_FW_F7_V1.15.0\Projects\STM32F746ZG-Nucleo\Examples\UART\UART_Printf.

int main(void)
{

 .....................

   UartHandle.Instance = USARTx;

   UartHandle.Init.BaudRate = 9600;

   UartHandle.Init.WordLength = UART_WORDLENGTH_8B;

   UartHandle.Init.StopBits = UART_STOPBITS_1;

   UartHandle.Init.Parity = UART_PARITY_NONE;

   UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;

   UartHandle.Init.Mode = UART_MODE_TX_RX;

   UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;

   if (HAL_UART_Init(&UartHandle) != HAL_OK)

   {
    Error_Handler();
   }

}

However, I generated the code using STM32CubeMX. I only made use of USART3 and confirmed that there is syscall.c in it. But nevertheless I can't see the print message. If anyone solved this problem, I would appreciate it if they shared it.

The following is the code I generated using STM32CubeMX.

int main(void)
{

  HAL_Init();

  SystemClock_Config();

  /* Initialize all configured peripherals */

  MX_GPIO_Init();

  MX_USART3_UART_Init();

  /* USER CODE BEGIN 2 */

  ...

}

static void MX_USART3_UART_Init(void)
{

  huart3.Instance = USART3;

  huart3.Init.BaudRate = 9600;

  huart3.Init.WordLength = UART_WORDLENGTH_8B;

  huart3.Init.StopBits = UART_STOPBITS_1;

  huart3.Init.Parity = UART_PARITY_NONE;

  huart3.Init.Mode = UART_MODE_TX_RX;

  huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;

  huart3.Init.OverSampling = UART_OVERSAMPLING_16;

  huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

  huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

  if (HAL_UART_Init(&huart3) != HAL_OK)

  {
    Error_Handler();
  }

}
Hans
  • 398
  • 2
  • 4
  • 14
  • where do you want to print it. You do not have any file system and magic "syscall.c" will not help as well. So where do you want to have it printed? – 0___________ May 12 '19 at 12:46
  • I didn't see any command of message transfer over uart in your code. – Vaibhav May 13 '19 at 10:18
  • I have that working. Very simple and no harder than other Nucleo. Do you have the drivers installed correctly? That is, check the device manager and make sure there is a VCOM entry. When I get back to the office, I will post the code. – Richard at ImageCraft May 13 '19 at 21:19
  • I want to see the print message through Tera term. I downloaded one zip file via internet and add UART3 initialize and call the HAL function. It works fine but this code was very old. I used the following command. HAL_UART_Transmit(); But when I check the STM32CubeMX example, I can use printf() function. So, I tried to use printf() but I coudn't. Finally, I copied syscall.c and I saw the print message using printf() function in example cold. And then I went back to the code that is generated STM32CubeMX, and call the printf() but I never see the print message. – Hans May 13 '19 at 22:36
  • Hi there. I resolved this issue. Add the following code into main.c, then you can use printf(). #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__ */ PUTCHAR_PROTOTYPE { /* Place your implementation of fputc here */ /* e.g. write a character to the USART3 and Loop until the end of transmission */ HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF); return ch; } – Hans May 16 '19 at 00:04

0 Answers0