2019-10-05 12:38 AM
Hi,
In my M4 program within while loop, I have made a for loop which iterates infinitely for 0.75 seconds like this but didnt work at all. I used time.h for that.
Are we allowed to make this kind of loop within the while loop in M4 program ?
Do you have any idea why it didnt work ?
clock_t begin;
double time_spent;
unsigned int i;
begin = clock();
for (i=0;1;i++)
{
/*do my staff */
if (VirtUart0RxMsg) {
Check_Delay(VirtUart0ChannelBuffRx, VirtUart0ChannelRxSize);
VIRT_UART_Transmit(&huart0, VirtUart0ChannelBuffRx, VirtUart0ChannelRxSize);
VirtUart0RxMsg = RESET;
}
time_spent = (double)(clock() - begin) / CLOCKS_PER_SEC;
if (time_spent>=0.75)
break;
}
}
Solved! Go to Solution.
2019-10-12 11:23 AM
I used the contents of HAL_Delay() function to make a loop which iterates an amount of seconds.
This issue can be closed.
2019-10-07 04:57 AM
Hello,
Maybe a basic SW issue, but I think you need to provide more details.
Do you try to debug it ? Do the loop hang on some function ? Is the loop exit too early ? Did you check the clock() value returned ?
2019-10-07 05:17 AM
I will debug it and write you the details...
2019-10-09 12:30 PM
how can something iterate infinitely for a finite amount of seconds?
2019-10-09 09:45 PM
You are right. There is a misunderstanding here.
I just mean "a loop which iterates an amount of seconds"
2019-10-12 11:23 AM
I used the contents of HAL_Delay() function to make a loop which iterates an amount of seconds.
This issue can be closed.
2019-10-12 11:23 AM
I used the contents of HAL_Delay() function to make a loop which iterates an amount of seconds.
This issue can be closed.