Problem with float/double on PSOC5

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.
Anonymous
Not applicable

I'm using a PSOC5 CY8CKIT-050 dev board with PSOC creator 3.3 and cannot work with floating point numbers. 

   

I made a small project to demonstrate the issue. I see that device.h cannot be found and I understand it should be generated automatically.

   

What am I missing?

   

Thanks in advance!

0 Likes
10 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Here is an example.

   

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Also set the heap to 0x0200 in the .cydwr file.

0 Likes
Anonymous
Not applicable

Thanks bobgoar, but that example doesn't work. I get two errors and one warning:

   

   Build errors: undefined reference to 'ftoa', undefined reference to 'LCD_PrString' (should be LCD_PrintString(), I think)

   

   Warning: assignment makes pointer from integer without a cast

   

Printing a float to the LCD was just a simple example of my larger problem that I can't use floats. Is there a compiler switch or something else I'm missing? My example compiles and runs, but the float and double are not displayed. In my real project I use atof() to convert a string to float, but the result is always 0. I tried just printing a float and found that it didn't work, and it appears the float is not supported.

   

I think the answer is along the lines of dimas response here: http://www.cypress.com/forum/known-problems-and-solutions/how-can-i-use-function-sprintf-psoc-design... but I haven't been able to figure it out yet. My directory did not contain a local.mk so I created on and added CODECOMPRESSOR:=$(CODECOMPRESSOR) -lfpm8c, but it still doesn't work.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

   

Make these settings also.

   

   

0 Likes
Anonymous
Not applicable

Thanks bobgoar, I mad those changes and still nothing...

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received
        I am going to try your program on a PSOC 5lp as I don't have your device which is the 100 pin version. I will see what I get.   
0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Here is your program and it is working fine. Just change the device back to your device in project and then device selector.  Turns out that you need 0x800 heap as 0x200 is not big enough. enjoy your program.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I also changed the lcd port to agree with my setup. You used P2(6:0) and I used P2(7:1) as that is how my board is wired .

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Here is a picture of the LCD.

   

0 Likes
Anonymous
Not applicable

Thank you! It is working now. Thanks for taking the time to help me and build the example!

0 Likes