I was developing a project on Arduino using a generic STM32H743VIT board. Due some drawbacks of the Arduino library, mainly concerning to ADC and time interrupts, I decided to change to STM32CubeIDE, that supposedly should be more efficient in utilizing the processor resources. After successfully make the transition to new code, the first tests were, let’s say, weird. Data processing was terrible slow. So I decided to make additional tests by measuring the computation time of sum, product, division and also some functions (cosine and exponential), and compare them with the same code running on Arduino IDE. The code I employed to measure the processor performance in CubeIDE and Arduino IDE were:
On STM32CubeIDE:
Code: Select all
{float fl_2, fl_3;
uint32_t itop = 1000000;
fl_2 = 1;
fl_3 = 0;
to = HAL_GetTick();
for (i = 0; i < itop; i++)
{
fl_2 = fl_2 + fl_3;
fl_3 = fl_2 + fl_3;
}
tf = HAL_GetTick() - to;
CDC_print_cp("Float sum (ms): ");
CDC_print_int((tf - tloop)/2);
CDC_print_ln();}
Code: Select all
{float fl_2, fl_3;
uint32_t itop = 1000000;
fl_2 = 1;
fl_3 = 0;
to = micros();
for (i = 0; i < itop; i++)
{
fl_2 = fl_2 + fl_3;
fl_3 = fl_2 + fl_3;
}
tf = micros() - to;
Serial.print("Float sum (ms): ");
Serial.print((tf - tloop)/2000);
Serial.println();
Serial.println();}