Can Psoc 6 M4 do floating point math.

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

cross mob
ChCe_4122011
Level 2
Level 2
First like received First like given

I am trying to use atan and it does not seem to be working. I have math.h included.

0 Likes
1 Solution

I understand that the math functions in the compiler is required, but it still would not work.......

I did get it to work by the following:

After setting the "m" in the Compiler-General, I looked at the Linker and saw that the Use newlb-nano Float Formatting was set to false so I changed it to True and it started working. This may be helpful for other users.

pastedImage_0.png

View solution in original post

4 Replies
RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

Yes, it can. The M4 even has support for floating point in hardware. You would need to change the compiler settings to take advantage of that.

Are you using PSoC Creator or ModusToolbox?

I am using PSoC Creator

0 Likes

You can follow these instructions to have access to the math library. It should work for PSoC 6 as well.

Using Math Functions in PSoC® Creator™ for the PSoC 4 or PSoC 5LP GCC Compiler – KBA93076

Unfortunately, PSoC Creator doesn't allow you to enable floating point support in a easy way. You need to follow these instructions:

Enabling Hardware Floating Point Compilation for Arm Cortex-M4 in PSoC Creator™ - KBA222890

Note you don't need the second step to make this work. If you don't use it, it will just take more time to process floating point operations.

I understand that the math functions in the compiler is required, but it still would not work.......

I did get it to work by the following:

After setting the "m" in the Compiler-General, I looked at the Linker and saw that the Use newlb-nano Float Formatting was set to false so I changed it to True and it started working. This may be helpful for other users.

pastedImage_0.png