AnsweredAssumed Answered

Multiple math functions calling issue

Question asked by k.jakub on Jul 27, 2013
Latest reply on Jul 27, 2013 by alex.001.T
Hi,

I've noticed weird problem when calling few math functions few times in a row or a loop like:

c = sin(3.0)+sin(5.0)+sin(5.0)+sin(5.0)+sin(5.0)+sin(5.0)+sin(4.0);

Actually I don't know what's going wrong but my application is audio-proccessing and sound coming out after deploying this code even when C variable is used nowhere else! It's just debugging code sample showing that adding few math functions makes something wrong to MCU and I don't even know how to to find the reason.

Problem also occurs with other math.h functions like tan or power.

My setup is uVision, Keil with project set as compiler defines:USE_STDPERIPH_DRIVER, ARM_MATH_CM4. My device is STM32F405 so it's with FPU that I'm using.

Included <math.h> files is from keil\arm\armcc\include standard location so it's original.

Note:
Executing simple x = sin(1.0) in loop works bad (many audio distortion) but when executed every like 8th iteration (or more rare) it works better so maybe math functions are so big and slow?

Outcomes