Using Math Functions in PSoC Creator for PSoC5's GCC Compiler

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

cross mob
Anonymous
Not applicable

Hi All,

   

 

   

There have been many contestants who have faced difficulty while using math functions in PSoC Creator using PSoC5's GCC Compiler even after including the 'math.h' header file.

   

Please undertake the following to eliminate the Build error:

   

Goto Project > Build Settings > Linker > General > Additional Libraries. Now type m in the Additional Libraries field.

   

Now, after the project Builds without any math error.

   

Refer to the KB article at the following link: http://www.cypress.com/?id=4&rID=42838

   

 

   

Regards,

   

dasg

0 Likes
9 Replies
Roy_Liu
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 10 questions asked

If I want to include other libraries, do I have to use another letter?

Roy Liu
0 Likes
Anonymous
Not applicable

Hi all

   
   
    I would like to know, is there trigonometric function viz Sin,Cos, Tan etc in Math.h or any other library of PSOC5?   
   
   
    Or   
   
   
    Have we to create new header file for the trigonometric function?   
   
   
    Referring the below link referring the same but last update was in 2008.   
   
   
     http://www.cypress.com/?id=4&rID=32927        
   
   

This may help me to proceed for my purchase of PSOC5 kit from other delevelopment kit.

   
   

Thank you

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I am taking lazy appoach to answer, but make a quick sample testbench project,

   

do a library call, and see if it works. The beauty of our tools today is ability to

   

self test ideas quickly in a GUI environment.

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I already used atan, sin etc, they (of course) work as expected. Just #include math.h

   

Bob

0 Likes
Anonymous
Not applicable

 Use "-lm" as linker command line option.

0 Likes
Anonymous
Not applicable

Hi,

   

I am using PSOC 4.0, trying to print values out of the code below

   

double x, y, result;

   

char  dataPrint[50];

   

  x = -10.0;

   

  y = 10.0;

   

  result = atan2 (y,x) * 180 / M_PI;

   

sprintf(dataPrint, "result %lf \r\n", result) ;
UART_DEB_UartPutChar(dataPrint);

   

I am not able to print the float/double values. I have followed instructions on the link http://www.cypress.com/?id=4&rID=87354 and also increased the heap size. please let me know if I am missing on anything.

   

Thank you,

   

Likhitha

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Do not use PutChar(), use PutString()

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thanks Bob. Silly mistake.. It works now..

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are always welcome with silly mistakes ;-))

   

 

   

Bob

0 Likes