2020-06-02 07:58 PM
Hello everyone, i have a problem about this condition, i use it for transmit a only one character to a function ( ChooseMenu )
Actually i convert decimal to ascii with if condition..
if (__HAL_UART_GET_FLAG(&huart3, UART_FLAG_RXNE) == SET)
{
uint8_t value;
uint8_t value2;
HAL_UART_Receive(&huart3, &value, 1, 100);
if (value == 48){
value2 = 0;
}
if (value == 49){
value2 = 1;
}
if (value == 50){
value2 = 2;
}
if (value == 51){
value2 = 3;
}
ChooseMenu(value2);
}
I have two question
1 : how to convert decimal to ascii ? when a write "1" in my serial monitor, it's not 1 in ascii but 48 in decimal but i need to transmit 1 to my menu not 48
2 : When i use 9600 baud if I write 1 many time, it crash i can't transmit other value but if i use 115200 baud, i did not crash why ?
I use STM32F746ZG
thanks for you help !
2020-06-02 09:26 PM
itoa()
value2 = value - 48;
2020-06-04 11:58 AM
How i can with Itoa i check and, it seems itao() do not convert decimal to character ?
2020-06-08 12:07 AM
I think that @Community member is meaning atoi(), not itoa().
Please check atoi().
Regards