I try to use atan2(x,y) but I have a problem in some cases. If I try this one: double x = 1; double y = 1; double z = atan2(x,y); I can compile the code with the CodeSourcery Toolchain. If I try the same with s16 or u16 instead of double it works also. But if I try to use my variables it does not work. vu16 ADCSensorValue[7]; double z = atan2(ADCSensorValue[ACC_X],ADCSensorValue[ACC_X]); I get: sensor.c:(.text+0xaa): undefined reference to `atan2' I tried also u16, s16 and copied the values befor atan2() but the same error. Please help me - thanks! Regards, Thorsten
double z = atan2((u16)ADCSensorValue[ACC_X],(u16)ADCSensorValue[ACC_X]); or double z = atan2((double)ADCSensorValue[ACC_X],(double)ADCSensorValue[ACC_X]); The step with double variable in between probably doesn't work because the optimizer throws it away...
u16 x[2]; x[0] = 12; double z; z = 12; double y = atan2 (z, x); It works. - If I use volatile vu16 x[2]; x[0] = 12; double z; z = 12; double y = atan2 (z, x[0]); I get an error. Also if I try this: vu16 x[2]; x[0] = 12; double zz = x[0]; double z; z = 12; double y = atan2 (z, zz); I get the error :-[ sensor.c:(.text+0x8e): undefined reference to `atan2' collect2: ld returned 1 exit status cs-make.exe: *** [main.elf] Error 1 I think the volatile is the problem - but I don't know how I can solve it. Regards, Thorsten [ This message was edited by: thorsten.raab on 30-11-2009 08:01 ]
But I don't know how I can solve it. Can anyone help me what I have to change in the codesourcery toolchain with the enviroment from lanchon (http://www.st.com/mcu/forums-cat-6304-23.html) Thanks Regards, Thorsten