2022-08-12 1:39 AM - last edited on 2025-06-02 3:07 AM by Andrew Neil
I use stm32cubeIDE
my code:
sprintf( mesaj, "xaccl = %3.3f /n ", xaccl );
HAL_UART_Transmit( &huart6, mesaj, sizeof(mesaj), HAL_MAX_DELAY );
how I can fix /n terminal problem?
thanks for answers
2022-08-12 1:48 AM
Use the proper escape character, ie \n
2022-08-12 2:31 AM
Might also point out that sprintf returns the length of the generated string, and sizeof() isn't suitable for strings.
2022-08-12 10:48 AM
And use snprintf() instead of sprintf(). Friends don't let friends use sprintf().