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.

a strange phenomenon with cos()


my project is under simulator .
to my surprise , my project sometimes run well and I got desirable output .
but sometimes my project get incorrect output .
I found my program fell into the cos function and can not get out .
after a while , i run the program again and i got desirable output.
how to explain this strange phenomenon? how to fix this problem?thanks

  • I'm sorry, there's not enough information here to act upon.  Also, the fact that it is intermittent will make it much harder to isolate.

    Do you have any interrupt handlers in your program?  If an interrupt is incorrectly written and occurs at an unfortunate time, it could cause such a problem.

    The next time you get stuck in cos, please halt the program and look at the value of the PC.  Is it a reasonable value within the function cos?  How about the value of SP; is it within the .stack section?

  • It is very odd that you see inconsistent results while running on the simulator.  A good guess is that something is not configured correctly, and/or several variables are not initialized.  It is all but certain the root cause problem occurred long before the cos function started.  You need to consider these possibilities and narrow this down.  As it is, there is nothing we can act on now.

    What target CPU do you use?  What version numbers of the tools?

    Thanks and regards,

    -George

  • my project is under simulator .
    to my surprise , my project sometimes run well and I got desirable output .
    but sometimes my project get incorrect output .
    I found my program fell into the cos function and can not get out .
    after a while , i run the program again and i got desirable output.
    how to explain this strange phenomenon? and how to fix this problem.thanks