Some Performance Measurements on STM32 MCUs

Maximum & Minimum Math Operation

All the operation is repeated 10000 times with random values

void APP_main() {
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14, 1);

  for (uint16_t i=0; i<10000; i+=1) {
    volatile float a = (float)rand();
    volatile float b = (float)rand();

    volatile float c = fmax(a, b);  // or fmaxf(); or fast_fmaxf()
  }

  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14, 0);

  HAL_Delay(10);
}

fast_fmaxf implementation

fmaxf()
fast_fmaxf()
fmax()

Trigonometry Math Operation

All the operation is repeated 1000 times with increasing values from 0 to 999

Interesting observation:

when using sinf() and cosf() from the standard math library to perform the calculation, the processing speed varies greatly depending on the magnitude of the numbers.

sinf(202.)
sinf(201.)

When the absolute value of the operand is greater than 201, the processing speed decreases by 10x.

Trig LUT

CORDIC

SPI AS5047P Reading

SPI Speed: 1.25MBits/s and 10MBits/s

PC14, Blocking Mode @ 1.25MBits/s
PC14, Interrupt Mode @ 1.25MBits/s
PC14, Blocking Mode @ 10MBits/s
PC14, Interrupt Mode @ 10MBits/s

There's an overhead of 1.7 us ~ 2.1 us when using interrupt mode compared to blocking mode.

Last updated