cancel
Showing results for 
Search instead for 
Did you mean: 

stm32h747i-disco uart8 transmitir error

wjian.2
Associate II

When i use uart8 for send data to arduino(add function in food recognition in the fp_vision_AI) ,when i use MX_USART8_UART_Init();(if i use // jump over this line the rest could run normally) the screen on the board get blocked(stopped),how could i check where i get wrong? anexo this parte of code.

Data i want to send as tipo of "%s %.0f%%"

sprintf(msg, "%s %.0f%%", NN_OUTPUT_CLASS_LIST[App_Context_Ptr->ranking[i]], *((float*)(App_Context_Ptr-;

HAL_UART_Transmit(&huart8,msg,10,1000);

2 REPLIES 2
Pavel A.
Evangelist III

Try to format only integer variables (remove the float one for now). If this works, you are using the "small" C library variant that does not support printing floats. Then decide: either round the float number to a long and format it with %l (%ul) or select the C library variant with float print support (see the project settings and CubeIDE user manual).

Note also that the number of bytes to send for HAL_UART_Transmit (the 3rd arg) is not necessarily 10. Consider using snprintf instead of sprintf  (especially at job interviews!)

wjian.2
Associate II

But the part i get block is MX_USART8_UART_Init() (this only show one objecto detective then do not change anymore, normally should change every 90ms),

static void MX_USART8_UART_Init(void)
{
  huart8.Instance = UART8;
  huart8.Init.BaudRate = 115200;
  huart8.Init.WordLength = UART_WORDLENGTH_8B;
  huart8.Init.StopBits = UART_STOPBITS_1;
  huart8.Init.Parity = UART_PARITY_NONE;
  huart8.Init.Mode = UART_MODE_TX_RX;
  huart8.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart8.Init.OverSampling = UART_OVERSAMPLING_16;
  huart8.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
  huart8.Init.ClockPrescaler = UART_PRESCALER_DIV1;
  huart8.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

  if (HAL_UART_Init(&huart8) != HAL_OK)
  {
    Error_Handler();
  }
 if (HAL_UARTEx_SetTxFifoThreshold(&huart8, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
   {
    Error_Handler();
     }
   if (HAL_UARTEx_SetRxFifoThreshold(&huart8, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
  {
   Error_Handler();
     }
   if (HAL_UARTEx_DisableFifoMode(&huart8) != HAL_OK)
  {
     Error_Handler();
   }
  /* USER CODE BEGIN USART1_Init 2 */

  /* USER CODE END USART1_Init 2 */

}
not the line of transmite.