- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i want to print float value in hyperterminal? which statements i will use here?how to print float value?
Solved! Go to Solution.
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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( ).
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i converted into string and then iam displaying but it comeslike only integers use printf floating point FP u
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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( ).
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sprintf not printing anything.......
how to print floating point?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Take a look at this:www.cypress.com/
and this :www.cypress.com/
It contains information about printing floating point value.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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().
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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 );
USB_PutString(reply_str);
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.
Thanks,
K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
K,
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.
Happy coding
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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. 😉
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Support your local pharma. I prefer Aspirin (Got my first education at BAYER)
;-))
Bob