2021-12-24 06:21 AM
Hi All,
I would like to send int32_t decimal number via USART, but with HAL_Uart_Transmit we can send uint_8.
Do you have any idea how I can do that?
Thanks.
2021-12-24 07:14 AM
HAL_UART_Transmit sends bytes. Whatever you have in those bytes it will send.
If you want to send binary data, convert the pointer and send.
int32_t x = 67;
HAL_UART_Trasmit(&huart1, (uint8_t *) &x, 4, HAL_MAX_DELAY);
If you want to send text data, convert it to a string and send.
int32_t x = 67;
char buffer[20];
sprintf(buffer, "%d", x);
HAL_UART_Trasmit(&huart1, (uint8_t *) buffer, strlen(buffer), HAL_MAX_DELAY);
2021-12-24 07:55 AM
Thank you so much.
It works for positive values. But I have still a problem with negative values. I can't send them because Hal_Uart_Transmit sends unsigned values.(uint8_t)
2021-12-24 08:03 AM