cancel
Showing results for 
Search instead for 
Did you mean: 

The execution time of memset() is different in different MCUs

fkst
Associate II

I now have two copies of basically identical code running in both MCUs. It was found that the two MCUs took different times to execute memset() of the same length.

Observe the running time by adding an IO flip before and after memset(). buffer is a global variable.

 

 

 

HAL_GPIO_WritePin(TEST_GPIO_Port, TEST_Pin, GPIO_PIN_RESET);
memset(buffer, 0, 256);
HAL_GPIO_WritePin(TEST_GPIO_Port, TEST_Pin, GPIO_PIN_SET);

 

 

fkst_0-1706777099863.png

lower is 6us, higher is 36us.(The loop runs with this value every time)

I can confirm that the frequency or settings of the two MCUs are consistent. And there are no operations like interrupts during running memset(). Micro used is STM32F746VGK. The library is libc_nano.a.

Any ideal? Is it related to memory alignment? thanks.

 

10 REPLIES 10

+1 Would also be agnostic to clock settings, say if HSE or PLL didn't start.

Would print out bus clock values as perceived by system, and DWT CYC counts over test function.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..