cancel
Showing results for 
Search instead for 
Did you mean: 

How to send and recevie data from serial print.

sangarius
Associate II

I'm using servo and driving it with servo motor. I want to print the servo degree via UART to serial. But im getting unknown characters. My code is;

/* USER CODE BEGIN 0 */
uint32_t potadc;
uint32_t servopot;
/* USER CODE END 0 */
 
/* USER CODE BEGIN 1 */
	char str[16];
  /* USER CODE END 1 */
 
 
 HAL_UART_Transmit(&huart2, (uint32_t)*str, sprintf(str, "Servo : %d\n", servopot), 0xFFFF);
 
 	  	  HAL_Delay(1);

Thanks in advance.

21 REPLIES 21
#if !defined  (HSE_VALUE)
  #define HSE_VALUE    ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */

sangarius
Associate II

I write this code inside the loop. It worked. Thanks.

int size_len = sprintf (str, "Servo : %ld\n", servopot);