AnsweredAssumed Answered

f4-discovery, fpu not working in timer interrupt?

Question asked by belchamber.ian on May 21, 2013
Latest reply on May 21, 2013 by waclawek.jan
Hi, I'm testing the f4 and the fpu. I have a small fpu test like this:

volatile float a=0;
volatile float b=.1;
int c;


for(;;)
    {
      GPIOD->ODR^=0x8000;
      for (c=0;c<100;c++)
        a=a+b;
    }

So by looking at PD15 on a scope I can measure how long it takes to do 100 adds of 0.1.

I'm using IAR and there is a project option to switch on / off the fpu.

If I put this in the idle loop, I get about 20us for no fpu and about 8us for fpu - not a big difference but I suppose it might be greater for divide, square root, etc. 

But if I try it in a timer interrupt, I don't get any improvement switching on the fpu. I've seen some hint of issues around stacking the fpu state, adding some assembler code etc. but not enough to work out what I actually have to do. Can anyone help?

Thanks  

Outcomes