sprintf from psoc creator 2.2 to psoc creator 4.0

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
GUPA_1336776
Level 1
Level 1

Hello,

   

 

   

I work from a project from psoc creator 2.2 with cypress kit-014 and i try to build it with new psoc creator 4.0 and cypress kit-059

   

with my new custom board.

   

How modify my project to work correctly with sprintf ?

   

sprintf doesn't work.

   

        // Calcul de la température en °Celcius
        Tx = ( Nx * q ) / 0.01 - 273.15;

   

        // Affichage du nombre Nx
        CharLCD_Position(3,0);
        CharLCD_PrintString("Nx =   ");
        CharLCD_PrintNumber(Nx);
        
        // Affichage de la température
        // avec le caractère spécial °
        CharLCD_Position(2,0);
        CharLCD_PrintString("T  = ");    
        sprintf(tstr,"%+9.4f",Tx);        
        CharLCD_PrintString(tstr);

   

 

   

Thank you for the help.

   

 

   

Patrick Guérangé

   

Teacher

   

France

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum.

   

When using sprintf()

   

Set "use newlib nano"

   

set "Use newlib nano float formatting" in Build Settings -> Linker

   

ans increase heap size to 0x0200 in system view.

   

 

   

Happy coding

   

Bob

View solution in original post

0 Likes
4 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Do you have this #include <stdio.h> at the start of the main.c ? Post you code so we can check it.

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Here is the manual on printf.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum.

   

When using sprintf()

   

Set "use newlib nano"

   

set "Use newlib nano float formatting" in Build Settings -> Linker

   

ans increase heap size to 0x0200 in system view.

   

 

   

Happy coding

   

Bob

0 Likes
GUPA_1336776
Level 1
Level 1

Hello,

   

 

   

It is ok with Bob information and before with cypress support.

   

Thank's.

   

Patrick

0 Likes