Hello,
Diana has left for her vacation so I'll put a few notes.
Hmmm, it is really up to you which method you will use. I usually prefer the simplest method which can be easily investigated after a months later when you forget a lot about ideas you had during solution. Only think also about any asynchronous process, for example, an interrupt which can be launched and served during loop or something that directs program flow somewhere else. Of course, it should not affect process if it only extends the loop cycle, however always think whether no background process is able to affect your polling method of bit status test.
I have used, usually (similar to your method 1):
****************************
static unsigned long cnt;
cnt = some value;
While( ( ! tested_bit ) && cnt ) // repeat while tested bit is not set and loop period is not exceeded
{
cnt--;
}
If( ! cnt ) report_error( WaitingLoopPeriodExceeded ) ;
****************************
HW counter, if I have understand it correctly, can be a problem if there is another interrupt which can cause loss of correct flag about time period overflow.
Best regards,
Ladislav