1 Reply Latest reply on Dec 7, 2019 1:52 AM by MoTa_728816

    FreeRTOS-Unable to print temperature on LCD

    NaMa_4430341

      Hi,

      I am using PSoC 5LP., trying to display temperature using freertos by creating two tasks. one to read and calculate temp and other to print on lcd. the lcd is not displaying temperature. I don't understand what is the problem. Please help me. The temperature is displayed like in the picture. Please see my code for your reference

      Thank you!

       

      IMG_5620.JPG

        • 1. Re: FreeRTOS-Unable to print temperature on LCD
          MoTa_728816

          Hi,

           

          I think that floating point format is not working.

          Perhaps, you need do one of following two.

          Note: I prefer (2) though.

           

          (1) Flag to use float print

          (2) Use "%d" instead of "%f"

           

          (1) Flag to use float print

          (1.1) From Menu  Project > Building Sttings

          000-build-settings.JPG

          (1.2) In the Build Settings Dialog

          ARM GCC ... > Linker > General > Use newlib-nano Float Fromatting

          Default : False

          Change is to True

           

          001-Linker.JPG

          (1.3) To use Floating format you may need to expand Stack Size and Heap Size

          in the DWR  System

          002-System-Help-Stack.JPG

           

          (2) Change sprintf format using "%d" instead of "%f"

          From

                           sprintf(str,"#T: %.2fC\r\n",curr_temp);

          to

                           sprintf(str, "#T:%d.%02dC\r\n", (int)curr_temp, (int) (100 * curr_temp)%100) ;

          or

                   if (curr_temp < 0.0) {

                         curr_temp *= -1.0 ;

                         sprintf(str, "#T:-%d.%02dC\r\n", (int)curr_temp, (int) (100 * curr_temp)%100) ;

                    } else {

                           sprintf(str, "#T:%d.%02dC\r\n", (int)curr_temp, (int) (100 * curr_temp)%100) ;

                   }

           

           

          moto