how to use the sin function

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to use the sin function

Jump to solution
2,313 Views
subbaraju
Contributor I
hi
i want to use the sine and cosine functions for my project implementaion. as i am new to codewarrior can any one help me in using the sin functions and printf statements i am working on m68hc12dp256 evaluation board.
i tried the following code
# include
void main(void){
int i=1; double y[10];
for(i=1;i10;i++){
y[i]=double (sin (double i));
}
}
if i try to compile it, giving errors saying error: c2450 expected .* + - etc., (expected 'double*' instead of 'double'); what it is meaning
secondly
i am not able to implement the printf statement?

thanking you in advance.

quick response is required.

regards
Subbaraju P.
Labels (1)
Tags (1)
0 Kudos
1 Solution
1,061 Views
CrasyCat
Specialist III
Hello
 
According to the code snippet you sent over, y is a local variable. is that right?
 
The table will take a lot of space on the stack, which might overflow.
 
Can you try to either define a bigger stack in the .prm file or define the table as a global variable.
 
Is that working better?
.
CrasyCat

View solution in original post

0 Kudos
4 Replies
1,061 Views
J2MEJediMaster
Specialist I
It's not clear from your code, but do you include math.h to define the sin/cos functions? Also, make sure that you're linking the correct library that contains both the trigonometric functions and the printf code. Check the readme.txt files that accompany the libraries in the lib directory for more information on what functions each library file contains.

---Tom
0 Kudos
1,060 Views
subbaraju
Contributor I


J2MEJediMaster wrote:
It's not clear from your code, but do you include math.h to define the sin/cos functions? Also, make sure that you're linking the correct library that contains both the trigonometric functions and the printf code. Check the readme.txt files that accompany the libraries in the lib directory for more information on what functions each library file contains.

---Tom


Thanks for your help now i am able to work with sine function. but i am facing the problem of memory. for the same program if i increase the array size of y to 20 then in debugging it is indicated that no memory FFe:2 at the bottom and the debugging is not proceding. please suggest a possible solution to the problem.
thanking you.
0 Kudos
1,062 Views
CrasyCat
Specialist III
Hello
 
According to the code snippet you sent over, y is a local variable. is that right?
 
The table will take a lot of space on the stack, which might overflow.
 
Can you try to either define a bigger stack in the .prm file or define the table as a global variable.
 
Is that working better?
.
CrasyCat
0 Kudos
1,061 Views
CompilerGuru
NXP Employee
NXP Employee
>y[i]=double (sin (double i));


I guess this should just be
y[i]=sin(i);


Why those extra double's?

About printf, is your problem a link time error of not finding TERMIO_PutChar?
If so, search this forum for TERMIO_PutChar.
To use printf with doubles, also make sure your STACKSIZE in the prm is big enough.

Daniel
0 Kudos