Printing floating-point values in PSoC Creator - KBA231059

Version 3

    Author: JeetendraA_51          Version: **

     

    Translation - Japanese: PSoC Creatorでの浮動小数点値の印刷 - KBA231059 - Community Translated (JA)

     

    The newlib-nano library is an open-source C library, which supports embedded MCUs. It is implemented with a focus on code and data size reduction. Thus, to save valuable flash memory, the newlib nano C library doesn’t support floating-point values.

    You should enable newlib-nano float formatting in PSoC® Creator™ to print floating-point values. See Figure 1.

    1. Select Project > Build Settings.
    2. Expand the options under the appropriate CPU in the left side panel.
      For dual-CPU PSoC 6 MCU devices, make changes in the settings of the appropriate core i.e., the core where the code for printing floating-point numbers is to be executed.
    3. Select Linker > General under the selected CPU.
    4. Change Use newlib-nano Float Formatting to True.

     

    Figure 1. Enabling Float Formatting in PSoC Creator

     

    Figure 2 shows an example code in main_cm4 of PSoC 6 MCU. Outputs observed on Tera Term using the UART Component in the Top Design are shown in Figure 4.

     

    Figure 2. Example Code to print float numbers

     

    The Tera Term outputs with ‘Use newlib-nano float formatting’ set to ‘False’ is shown in Figure 3.

     

    Figure 3. Tera Term Output with ‘Use newlib-nano float formatting’ set to ‘False’

     

    Tera Term output with ‘Use newlib-nano float formatting’ set to ‘True’ is shown in Figure 4.

    Figure 4. Tera Term Output with ‘Use newlib-nano float formatting’ set to ‘True’’