hi guys , iam karthik . iam currently doing a project of implementing "an angle calculating algorithm" in TMS320C32.I hv an FPGA interface part which is complete.Now i find a problem in implementing the trignomentric functions namely sine and cos functions .Can anyone suggest me a way to make out this cos function implementation.I hv code composer studio 3X , but iam not able to make out this . any help will be greatly appreciated. regards karthik 

implementing sine cos functions in TMS320C32
Started by ●February 7, 2004
Reply by ●February 12, 200420040212
Hello Karthik One of the primary problems with Ctranscendentals (and indeed many functions) is that as an ANSIC compiler the compiler is not required to check for C prototypes. Kind of weird, but true. When no prototype is found, the inputs and outputs are assumed to be of type 'int'. Therefor the expression 'y=cos(x)' would be interpreted as, convert X to an integer, pass it to the function _cos and expect an integer return value. If it is any consolation the compiler will let you know if a function being called does not match a previosuly defined prototype. As for the specific error numbers 2154, 2140, I dont know these, but the hotline may know there meaning (I am not the hotline). Usual suspects in this case will be that you have tried to load the program to an improper or nonexistent memory location in which case you would want to change the linker command file. Another would be that, if this were a runtime error, that the stack has overflowed. Possibly of interest  If the cos() function is being used to compute successive values of cosine like cos(n), cos(2n), cos(3n)... it may be best to compute a rotating phasor. static float Wr = 1; // signal as R/I phasor static float Wi = 0; void set_freq(float W) { Wr = cos(W); Wi = sin(W); } float siggen(void) { static float Sr = 1; // signal as R/I phasor static float Si = 0; float f; f = (Sr * Wr)  (Si * Wi); Is = (Si * Wr) + (Sr * Wi); Rs = f; f = 1.5  0.5*((Sr*Sr)+(Si*Si)); Sr *= f; Ir *= f; return Sr; } Hope this helps, Keith Larson ==================================== At 03:28 PM 2/7/04 +0000, you wrote: hi guys , iam karthik . iam currently doing a project of implementing "an angle calculating algorithm" in TMS320C32.I hv an FPGA interface part which is complete.Now i find a problem in implementing the trignomentric functions namely sine and cos functions .Can anyone suggest me a way to make out this cos function implementation.I hv code composer studio 3X , but iam not able to make out this . any help will be greatly appreciated. regards karthik ++  Keith Larson   Member Group Technical Staff   Texas Instruments Incorporated     2812743288     www.micro.ti.com/~klarson (TI internal web only)  +  TMS320C3x/C4x/VC33 Applications     TMS320VC33   The lowest cost and lowest power 500 w/Mflop   floating point DSP on the planet!     Web: focus.ti.com/docs/toolsw/folders/print/tmdsdsk33.html   Code: wwws.ti.com/sc/psheets/sprc147/sprc147.zip  ++ 