LDR and STR asm instruction different execution time?
Hello. I am using STM32F4279ZI MCU with FreeRTOS. I want to compare efficiency of bare-metal and OS based program implementation. While doing some tests I have noticed that the same function called from bare-metal aplication is much slower than that called from FreeRTOS despite the assembler code is the same (I turned off all compiler optimalization).
After more detailed tests I have noticed that LDR and STR asm instructions execute 1 cpu cycle longer in function called from main() function than that one called is FreeRTOS task.
I measure execution time in cpu cycles with DWT->CYCCNT register.
Do you know or do you have any idea what is the reason of this difference?
Here is my example code. I deleted all unnecessary code:
void foo()
{
uint32_t j = 0;
uint32_t i;;
DWT->CYCCNT = 0;
i = 0;
for (; i < 10000; i++)
{
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
}
j = DWT->CYCCNT;
printf("%d\r\n", j);
}
void task(void* param)
{
foo();
for (;;)
{
};
}
int main(void)
{
foo();
xTaskCreate(task, "task", 100, NULL, 1, NULL);
vTaskStartScheduler();
}