- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I got a long codes which used to calculate some statistical parameters using PSoC MCU. To reserve precision, I tried to print the result using XBee through an UART interface. However, the PSoC doesn't print any floating or double character to the XBee.
Since it is quite a long code, I will only extract the part which might cause the problem.
================================================================================
#include <device.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
//..............Many other codes.............
char DataBuffer[50] = {'\0'};
int16 array_ADC2[8192]; //Channel for ADC
//Mean
for(i=0; i<8192; i++)
mean += ((double)array_ADC2)/8192;
sprintf(DataBuffer, "Mean: %f\r\n",mean);
UART_PutString(DataBuffer);
================================================================================
However, one the UART interface, it onlyshows "Mean: " without printing out the double-typed variable. I tried to print it with int and it actually works so perhaps there is some configuration/coding that I missed out?
Thank you very much.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not knowing what version of Creator you are using the nano library had
to be enabled for psoc -
http://www.cypress.com/?id=4&rID=87354 newlib-nano -u_printf_float command line linker
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dana,
Thanks for the reply. Currently I am using PSoC Creator 3.0 SP2 (3.0.0.3140).
*******Update********
Thanks for the article! Now it works like a charm!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad I could help.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ha, the old printf problem again.
I think a little button on the IDE tu "Use Nano" or Not would save a lot of time.
By the way, is double the preferred variable to use instead of float? Saw a post somewhere suggesting double should be preferred over float type?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am using PSOC 4.0, trying to print values out of the code below
double x, y, result;
char dataPrint[50];
x = -10.0;
y = 10.0;
result = atan2 (y,x) * 180 / M_PI;
sprintf(dataPrint, "result %lf \r\n", result) ;
UART_DEB_UartPutChar(dataPrint);
I am not able to print the float/double values. I have followed instructions on the link mentioned above http://www.cypress.com/?id=4&rID=87354 and also increased the heap size. please let me know if I am missing on anything.
Thank you,
Likhitha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you please post your complete project or a shortened version that shows the error so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob