This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430G2452 Calculate sin value wrong

Hi, All

I didn't understand why I calculate the sin value is wrong as below, especially the value all are 1 when the angle above 50. 

###########################################

compiler is TI v4.2.1

###########################################

do you help me introduce it? thank you very much!

  • anybody take a look for this case? thanks...

  • I think this might belong in the CCS or TI compiler forums.

    It looks like the expressions window is not showing the results of those calculations as you might expect it to.

    For example, f(=sin(40*3.14/180)) is shown as 0.69777... when the correct value is approximately 0.6425. Rather than showing the value of f (= sin(40*3.14/180)) = 0.6425 the expressions window is showing 40*3.14/180=0.69777...

    Try printing the results to a console/terminal on your PC using CIO or UART. Alternatively you can use the memory view to look at the real contents of the memory addresses shown for c-h, though I don't remember if CCS can display double precision floating point format in that view.

    EDIT: By the way, I tried a quick test of sin on FR5969 and it worked fine as far as I could see. That was with TI compiler v4.3.4, however.

  • Hi,  Robert

    Thanks very much for your replied. I think I have found the issue root under your guide. due to the variable is never used, so the maybe the register value has been released. but it confused me by below display is correct.

**Attention** This is a public forum