Brian Smith

Problems with cosf() and sinf()

Discussion created by Brian Smith on Jul 30, 2006
Latest reply on Jul 31, 2006 by Shannon Roberts
Using CodeWarrior IDE for HC(S)08 version 5.7.0, with processor expert plug-in. Code is in C and target is the Freescale MC908GP32. The problem is that whenever I try to use cosf() or sinf() (or sin() or cos() for that matter...) the microcontroller goes crazy (random pins going high and low) and eventually the main loop just stops running altogether. As soon as I remove the lines of code containing the trig functions everything else works fine. Anyone know what's up???

Code:

#include "math.h"

float theta=3.14159; //it doesn't matter what value
float x;

for(;; ){
x=sinf(theta); //or x=cosf(theta), once again it doesn't matter
}

P.S. It's urgent!!! This is for a school project due by October, see http://www.geocities.com/thisisbrians/ for details.

Outcomes