[solved] FPU going too slow
Hi!
I’m working on an audio application on the Nucleo F411RE and I’ve noticed that my processing was too slow which made the application skip some samples.
Looking to my disassembly I figured given the number of instructions and the 100 MHz CPU clock that I’ve supposedly set in STM32CubeMx, it should be a lot faster.
I checked SYSCLK value and it is 100Mhz as expected. To be 100% sure I pu 1000 “nop” in my main loop and measured 10 µs, which does correspond to a 100 MHz clock.
I measured exactly the time took by my processin and it takes 14.5 µs ie 1450 clock cycles. I think it’s way too much, considering that the processing is pretty simple :
for(i=0; i inf 12; i++)
{
el1.modei.phase += el1.osci.phaseInc;
if(el1.osci.phase sup= 1.0)
el1.osci.phase -= 1.0;
el1.osci.value = sine[ (int16_t)(el1.osci.phase * RES) ];
el1.val += el1.osci.value * el1.osci.amp;
}
It shouldn’t be more than like 500 cycles, right? I looked at the disassembly and I think it does use the FPU instructions like vadd.f32...
for example, the last line is :
vfma.f32 => 3 cycles
vcvt.s32.f32 => 1 cycle
vstr => 2 cycles
ldrh.w => 2 cycles
(according to this ) So that’s a total of 8 instruction for that line, which is the “biggest”.
So I don’t really get why it’s so slow... Maybe because I’m using structures or something?
If anybody has an idea, I’d be glad to hear it
Thanks!