Lesson 06: Floating Point Problem in PSoC Creator 3
In the PSoC Creator 3, the default library is newlib-nano. It is a leaner, which leaves more flash and memory for your design, and weak references the code that handle floating point as a part of stdio. Therefore, some of the floating point function will not work as you expect, such as:
sprintf( str, "Testing: %f", 12.35); // is not working with Creator 3
If you have to use the floating point in your code, you can use following steps to eable the floating point support:
- Enable "Use newlib-nano Float Formatting"
Build Settings ➤ Linker ➤ General ➤ Use newlib-nano Float Formatting:Must be set to True for floating point
- You also need to increase Heap size
From the Workspace Explorer panel, double-click on the yourproject.cydwr file to open Design-Wide Resource (DWR) panel. In the System tab, edit the Heap Size (bytes) to 0x200
- Done, rebuild you code and try it!!