PSOC Creator 3.1 still can't do floating point, consistent crash

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

cross mob
WaMa_286156
Level 5
Level 5
First comment on blog 100 replies posted 50 replies posted

I tried following the video for the PSOC Voltmeter. 

   

  sprintf(tmpString,"%+1.3f Volts", adcVolts);

   

  fails, printing  " Volts"  on the LCD.   This is with "Use newlib-nano" and "Use newlib-nano Float Formatting"

   

 (-mthumb -march=armv7-m -mfix-cortex-m3-ldrd -Wl,-Map,${OutputDir}/${ProjectShortName}.map -T .\Generated_Source\PSoC5\cm3gcc.ld -g -specs=nano.specs "-u _printf_float" "" -Wl,--gc-sections)

   

  If you set Use newlib-nano to false, it prints "+"

   

  If you set "Use newlib-nano float format" to false along with "Use newlib-nano" to false, it prints "+"

   

  under no conditions does your sprintf() floating point library work.  If you use %d with a number it prints, so sprintf() is working.

   

   This bug has been around a long time, since 2013.  Do you expect to fix it?  It is not important, I agree, but it does not let me feel good about the product, knowing certain parts of the libraries don't work.

   

  attempting to add in main.c the following line before main(){}

   

asm(".global_float_format")

   

crashes PSOC creator at the first quote ".  Always.

   

   Of course, an obvious work around is to multiply the floating point number by 1,000 and then print the %d number, and display the results in millivolts. 

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

Welcome in the forum.

   

Yes, there are some issues with sprintf(), follow this thread to get a solution www.cypress.com/

   

First try would be to increase stack size.

   

 

   

Bob

View solution in original post

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

Welcome in the forum.

   

Yes, there are some issues with sprintf(), follow this thread to get a solution www.cypress.com/

   

First try would be to increase stack size.

   

 

   

Bob

0 Likes
WaMa_286156
Level 5
Level 5
First comment on blog 100 replies posted 50 replies posted

  Thanks for the quick reply!  I appreciate it.  I had read the previous post in order to fix this, to no avail.  I think those fixes used to work in 2.x, but 3.x has broken something.

   

   Increasing the stack size in .cydr->System_>Stack Size to 0x1000 (4k) from 0x0800 (2k) did not help.  Neither did increasing the Heap size to 4k bytes.

   

  So far, it appears the floating point is permanenly broken.

   

  Where can I find out about available libraries?  I downloaded the document manager and tried finding how to force or load libraries with PSOC creator, and the User Guides are "sunset reviewed" and talk about ImageCraft and Hi-Tech compilers, neither of which are being used.  Other documentation said everything was automatically handled.  I sincerely doubt this, as nothing I've tried get sprintf() of A/D values working, unless the asm() call, which crashes the Creator as it is typed in, would fix it.

   

  On the plus side, the Delta Sigma A/D is fairly accurate.  My 10 year old Radio Shack Multimeter reads 0.399 volts, my expensive Fluke reads 0.402 volts, and the A/D reading is 0.401 (without rounding up). The RS meter gets less accurate over 1v, (being off about 5 mv)  but the Fluke and your A/D agree within 1 mv.

   

 

   

 UPDATE:  Adding the asm(".global _printf_float"); in the ADC.c file caused the PSoC Voltmeter project to work, with floating point, without touching the rest of the project (except maybe stack and heap)

0 Likes
Anonymous
Not applicable

Hey anybody can  helpme, i have a Cy8ckit-50 with PSoc 5lp and asm(".global _printf_float"); estructure in LCD.C not work, i build and programm (A complete project walk-thru, making a simple voltmeter with PSoC Creator), for youtube, and  My Adc not work, the screen is blocked and don't run the ADC, only showme +/- 0.000 value it's mean anly zero on screen with i move my potenciometer,
What's up?.
 

0 Likes
WaMa_286156
Level 5
Level 5
First comment on blog 100 replies posted 50 replies posted

  OOPS! I did not mean to say "Get the A/D working", I meant to say "Get sprintf() working"  I apologize! fixed.

0 Likes
WaMa_286156
Level 5
Level 5
First comment on blog 100 replies posted 50 replies posted

 Finally fixed it, for PSoC5LP

   

 entering the following in main.c for the PSoC Voltmeter project crashed PSoC creator *every* *single* *time*:

   

asm(".global _printf_float");

   

  HOWEVER

   

entering that *same* string in ADC.c did NOT crash PSoC Creator.

   

Once I did that, the floating point finally worked.

   

The library that crashed was libclang.dll, which I assume is the text beautifier and problem indicator for the C file in Microsoft Visual Studio.

   

  SO TO FIX THIS PROBLEM, TAKE THE DEFAULTS IN THE BUILD AND PUT THE asm(".global _printf_float"); IN ONE OF YOUR C FILES.  IT MAY CRASH IF YOU PUT IT IN MAIN.C, BUT IT MAY WORK ELSEWHERE.

   

  (Upper case attention grabber for those who are quickly scanning for a fix)

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

There was a bug reported in "Clank" which is the online-code checker.

   

Make sure that the commented line

   

/* [] END OF FILE */

   

is followed by one or more empty lines.

   

 

   

Bob

0 Likes
WaMa_286156
Level 5
Level 5
First comment on blog 100 replies posted 50 replies posted

  Just added blank lines after the  END OF FILE, still get the crash.  (A blank line was already there)

   

  If I put the asm(" anywhere before the int main(), it does not crash. (anywhere before the #include <xx.x> statements)

   

  If I add int main(); before the int main() { function beginning, then I can add asm(" without a crash, as long as I add it before the int main();  If I add the prototype and add the asm(" after the prototype, I get a crash, if it is just before the int main() { function.

   

   So, to add it to the main.c file, add  an int main(); prototype and add the line before the prototype.

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

Welcome in the forum, Fernando.

   

I would suggest you to

   

1st: Upgrade Creator to latest version 3.3

   

2nd: In .cydwr view, "System" tab increase the heap size to 0x0200

   

3rd: In Project -> Build settings -> Linker -> use newlib nano float formatting: set to true

   

When still stuck, post your complete project, 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.

   

 

   

Happy coding

   

Bob

0 Likes