You are here

Problem with float/double on PSOC5 | Cypress Semiconductor

Problem with float/double on PSOC5

Summary: 10 Replies, Latest post by wjdavis_1525081 on 29 Aug 2016 10:38 AM PDT
Verified Answers: 3
Last post
Log in to post new comments.
wjdavis_1525081's picture
User
5 posts

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!

user_242978793's picture
User
1351 posts

Here is an example.

user_242978793's picture
User
1351 posts

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

wjdavis_1525081's picture
User
5 posts

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-... 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.

 

 

 

user_242978793's picture
User
1351 posts

Make these settings also.

wjdavis_1525081's picture
User
5 posts

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

user_242978793's picture
User
1351 posts

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.

user_242978793's picture
User
1351 posts

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.

user_242978793's picture
User
1351 posts

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 .

user_242978793's picture
User
1351 posts

Here is a picture of the LCD.

wjdavis_1525081's picture
User
5 posts

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

Log in to post new comments.