如果你得到的是Float类型的话,用UART_uartputchar()打印输出是不可以的,默认情况下PSoC Creator是不支持浮点打印,你要做浮点打印还需要设置一下PSoC Creator的环境,具体操作如下:
方法一:Enable floating-point formatting support in newlib-nano
Open the Project > Build Settings > ARM GCC 4.7.3 > Linker > Command Line. Add “-u _printf_float” in the Custom Flags field. This change will result in an increase in flash usage on the order of 10 Kbytes to 15 Kbytes and a small increase in RAM usage in your application.
方法二:Change the whole library
The second method is to change the whole library. Open the Project > Build Settings > ARM GCC 4.7.3 > Linker > General and set “Use newlib-nano” to false. This switch in the library to newlib will enable support for all runtime library features but will result in an increase in flash usage on the order of 25 Kbytes to 35 Kbytes and an increase in RAM usage on the order of 2 Kbytes.