i want to print float value in hyperterminal? which statements i will use here?how to print float value?
To display a float value on hyperterminal, you need to first convert it into a string using sprintf function and then send it via UART.
i converted into string and then iam displaying but it comeslike only integers use printf floating point FP u
Assuming you are trying to print a float driven by PSOC, as mentioned before,
you use sprintf( ) with proper formatting command. sprintf( ) converts numeric
to a string, and places it into a buffer, null terminated. You then use UART API
to send char string to Hyperterminal. So declare a char buffer, say 10 - 15 characters,
and apply sprintf() to load it.
See attached doc for examples of formatting for sprintf( ).
sprintf not printing anything.......
how to print floating point?
Take a look at this:www.cypress.com/
and this :www.cypress.com/
It contains information about printing floating point value.
sprintf() really does not print anything, but it stores the converted values in a string that can be printed or sent via UART or USBUART o a PC. When the format is a string residing in flash (as usual) you have to use csprintf().
I know this is an old post but my issue is related and I'm quite hesitant to add another forum post with the same issue. I was wondering how to make sprintf work with my USBUART.
I am using the USB_PutString(reply_str) API . I had no issue displaying any string from my other functions however for my ADC, I would like to display the mV calculation in the hyperterminal.
I am using PSoC5 Pioneer Kit, I had connected my ADC pin to the VR so as I could emulate Voltage reading using the built in potentiometer of the kit. I had this tested first with the kit's LCD and I had no problem displaying the values. When I applied it in the hyperterminal, I not receiving any values. This is my code excerpt:
result = ADC_SAR_Seq_GetResult16(chan);
res = ADC_SAR_Seq_CountsTo_mVolts(result);
sprintf(reply_str, "%f mV", res);
while ( USB_CDCIsReady() == 0u );
Basically, the way this project works is that the USB Host will issue a command and the Pioneer kit will reply with the GPIO State. I've attached here an example of GPIO state inquiry for Digital IO (Port 4, pin 3) and Analog IO (Port3,Pin1).
For the digital pin inquiry, I was able to return the state. I was hoping to do the same for the ADC wherein I could display the value.
not a good idea to post an "old" problem in a PSoC1 forum when related to PSoC5 ;-)
Make sure you are using the latest Creator 3.3 and latest components.
sprintf() needs some settings to work:
In "Project -> Build settings -> Linker" you'll have to set "Use newlib nano" and "Use newlib nano float formatting"
In .cydwr-view (where you assign the pins) under "System" tab set the heap size to 0x100, better 0x200.
Bob, just wanted you to know I have been beating my head against the wall on this issue for several hours now... and then I found your post. Problem fixed!! Thanks a bunch! You saved me a fortune in Ibuprofen. ;-)
Support your local pharma. I prefer Aspirin (Got my first education at BAYER)