|
Probably best to set a timer with interrupt, then you can count the number of times the interrupt goes off. Or if you have an external real time clock it might have the functionality to interrupt you at a given time. Or if you just want to count off five minutes, write a counter subroutine, work out how long one iteration takes (remembering to take EVERYTHING into account - branches taking longer if they branch than if they don't, allowing for any interrupts etc (this also depends on how accurate you want to be)), then just count for the appropriate number of iterations to pass five minutes. So if your loop takes 100ns to count to 1, then 5 min=5*60*10,000,000=300,000,000. Count to 300 million and you're done. If you want to run something every five minutes then the counter approach will throw you off eventually unless you count all the instructions in your program (very tedious).
|