FreeRTOS-Unable to print temperature on LCD

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
NaMa_4430341
Level 1
Level 1

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

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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

View solution in original post

0 Likes
1 Reply
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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

0 Likes