Tool/software:
how can i get decimal values in serial port ?
i excuted example code in my tms4357lc4357 herculis development kit .
i am getting hex value in serial terminal.
Thanks in advance.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
how can i get decimal values in serial port ?
i excuted example code in my tms4357lc4357 herculis development kit .
i am getting hex value in serial terminal.
Thanks in advance.
Hi Ashutosh,
how can i get decimal values in serial port ?
If you want to display the decimal values on the serial port directly then you should need to convert the corresponding decimal values into the ASCII string. And then you have to send this string to the serial port and there you can see the values in ASCII format at serial terminal.
To do this you can use "sprintf" function in the stdio.h library.
For example, you can verify below code:
In above code "Size" is a decimal value, so they are passing this decimal value to the sprintf API, what sprintf will do is that it will convert this decimal value into the ASCII string and stores this into the input buffer, in this case it is "Numberstr".
Now after this you can send the buffer data as byte by byte to the serial port.
To learn more about sprintf you can refer below link as well:
sprintf() in C - GeeksforGeeks
--
Thanks & regards,
Jagadish.
Thanks for your reply , i want to see my adc voltage of (1 to 2.5 volt connected with pot) value in decimal and float format in serial port , but by default it is hexa formet , thanks a lot for previous reply.
Hi Ashutosh,
Using UART or SCI you can't send float values directly.
The UART or SCI only sends the data interns of bytes, and each byte value will be in between 0x00 to 0xFF (that means 0 to 255). We can't send anything other than this through UART or SCI.
Example:
If you want to send 1.5 value to the UART, you can't simply directly send it.
To send this 1.5 float value, you need to send ASCII value of each character.
Refer below ASCII table
ASCII table - Table of ASCII codes, characters and symbols (ascii-code.com)
So, using above table, the below are the decimal and Hex values of 1.5 value
'1' => 49 (0x31)
'.' => 46 (0x2E)
'5' => 53 (0x35)
So, to send this 1.5v value to the serial port you need to send the 0x31, 0x2E and 0x35 bytes. And at receiving end, if you view the data in the ASCII mode then you can see that 1.5 in the display.
That is the reason i am saying to use the "sprintf" to convert your float value into a string.
--
Thanks & regards,
Jagadish.
love you a lot boss thankyou so much , now i am able to see adc value in float but some calibration is required for getting accurate value .