- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Tags:
- freertos
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
(1.2) In the Build Settings Dialog
ARM GCC ... > Linker > General > Use newlib-nano Float Fromatting
Default : False
Change is to True
(1.3) To use Floating format you may need to expand Stack Size and Heap Size
in the DWR System
(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