Two issues with snprintf and floats | Cypress Semiconductor
Two issues with snprintf and floats
I was attempting to use snprintf to format floats into strings to print over UART and I ran into two issues.
Issue 1: "Use newlib-nano Float Formatting" doesn't work.
With the default settings it works perfectly for integers but attempting to use it with floats doesn't work even with the "Use newlib-nano Float Formatting" set to true it does not print the float.
Value of pi is: to 2dp
In order to get it to include support for floating point printing I had to follow the instructions from http://www.cypress.com/?id=4&rID=87354 and add -u _printf_float to the command line manually and set "Use newlib-nano Float Formatting" to false.
Issue 2: Using snprintf with floats causes the PSoC 4 to hang unless the heap is increased to at least 256B
If you attempt to use snprintf (or sprintf) with floats the processor will jump to IntDefaultHandler and hang. In PSoC Creator 3.1 the default heap size was decreased to 128B from 256B which likely caused this issue.
I have attached a project that should reproduce these issues.