cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable

Hi,

   

I am having a problem writing a floating point value to the UART. I read about an issue at the link below, and my problem likely is related somehow .

   

http://www.cypress.com/?app=forum&id=2492&rID=86619

   

The problem is that the UART terminal does not respond at all when attempting to write floating point data to it. This happens even if you set the compiler to not use the nano libraries.

   

I know my UART setup is working because integers and ASCII strings print flawlessly.

   

Thanks for any suggestions or workarounds.

0 Likes
8 Replies
JoMe_264151
Expert II

Info is a bit short, what is the definition of MyVar? Better post your complete project.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Here is the project. What it does is it monitors the mains voltage and periodically generates peak and RMS voltage reports.

0 Likes
odissey1
Honored Contributor II

this should work

   

odissey1

   

 

   

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

   

#if defined (__GNUC__)
    /* Add an explicit reference to the floating point printf library */
    /* to allow the usage of floating point conversion specifiers. */
    /* This is not linked in by default with the newlib-nano library. */
    asm (".global _printf_float");
#endif
 
      char strMsg1[64];//output UART buffer
      ...
      sprintf(strMsg1, "%f", 0.01); 
      UART_1_PutString(strMsg1);

0 Likes
JoMe_264151
Expert II

Have a look at this thread www.cypress.com/ Robyn explains the why and how2.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I tried the above sugessions. The UART is still not printing the data. What is going on? It worked just fine prior to release 3.0.

0 Likes
HeLi_263931
Honored Contributor II

Kind of a wild guess: try to increase the head size for your project. There were reports that the 128 bytes its now set to by default might be too small.

0 Likes
HeLi_263931
Honored Contributor II

See also http://www.cypress.com/?app=forum&id=2492&rID=70447&start=21 (right at the bottom) - the heap size seems to be the solution.

0 Likes
Anonymous
Not applicable

I adjusted the heap size and that fixed my original problem. I now am having a new problem. The UART arbitrallarly simply just stops writing floating point data to the UART.

   

I was thinking the interrupt was the cause, but I took it out of the loop. Same problem.

   

Is there a memory leak or something going on?

   

My updated project is attached.

0 Likes