Problem Debugging a sin function code

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

Problem Debugging a sin function code

2,419 Views
krude
Contributor I
Hi, I am currently trying to run a program with the follow code but my watchdog always reset. I tried to turn off the COP by changing SOPT_COPE to 1 at main.cpp but I still don't get it to stop at the breakpoints I set. But anyway, can somone take a look at my code and tell me what's wrong, can? Thank you. I tried to isolate the problem and apparantly, it's got to do with the sin function I used. Thank you.

int iNsample,in;
float fsine,fsinCoM,fFreq,fdT,fsinCo;

iNsample = 32;

fFreq = 440.0;

////----Maths function----\\\\\

fdT = 1/(fFreq * iNsample);

fsinCo = 2.0 * _M_PI * fFreq * fdT;


for(in=0; in
{
fsinCoM = fsinCo * in;
fsine = (sin(fsinCoM) + 1) * 100;
sinearray[in] = (int) fsine;

};//end for
Labels (1)
0 Kudos
1 Reply

498 Views
krude
Contributor I
I solved the problem. Thanks for reading!haha... The problem is actually caused by the watchdog timeout. The watchdog timed out before my sin function can complete its computation. Just set the watchdog timeout to a longer period. :smileyhappy: Maybe someone have a better solution can share.
0 Kudos