engr_joni_ee
Advanced Member level 3
Hello,
I am having a program in MPLAB in which I have a while loop within the main function. There are two tasks in the while loop, each task takes between 400 - 450 m sec which I don't know how to calculate exactly but I need to put a delay at the end to wait until the next second and then the next iteration of the while loop should start. For example if both tasks need 900 m sec then it should wait for 100 m sec and then the next iteration of the loop should begin. The question is which function in MPLAB puts such delay which is until next second ?
I am having a program in MPLAB in which I have a while loop within the main function. There are two tasks in the while loop, each task takes between 400 - 450 m sec which I don't know how to calculate exactly but I need to put a delay at the end to wait until the next second and then the next iteration of the while loop should start. For example if both tasks need 900 m sec then it should wait for 100 m sec and then the next iteration of the loop should begin. The question is which function in MPLAB puts such delay which is until next second ?
Code:
main ()
while (1)
{
task 1 takes some m sec
.
.
task 2 takes some m sec
.
.
delay until next second
}