Tool/software:
I have a program on a TMS320F28379D microcontroller.
My program structure is as follows:
void main(void)
{
Init_program(); // init clock, timer, hardware, peripheral, software variable.
delay_ms(5000);
start_flag = true;
while(1)
{
SW_Task_1(); // My application
}
}
My delay_ms() funtion is:
void delay_ms(uint32_t time_ms)
{
int16_t i;
while(time_ms--)
{
for(i = 0; i < 10000; i++);
}
}
Initially, I used CpuTimer0 and debug to measure, the execution time of the delay_ms(5000) function was approximately 4s.
But when I change the program to structure:
void main(void)
{
Init_program(); // init clock, timer, hardware, peripheral, software variable.
delay_ms(5000);
start_flag = true;
while(1)
{
SW_Task_1(); // My application 1
SW_Task_2(); // My application 2
}
}
This time, I measured the execution time of the delay_ms(5000) function to be about 4.7s.
I added a few SW_Tasks and the measured time changed, from 3.8 - 5.4s.
Please help me explain this phenomenon.