| ??? 05/30/02 03:37 Read: times |
#23626 - RE: Need some expert help on a timing issue |
How's this?
void main (void)
{
unsigned long timer_tick;
while (1)
{
/*-------------------------------------
Wait for P2.0 to go lo.
-------------------------------------*/
RESET_LOOP:
while (P2.0)
{
P0.0 = 0; // This was not specified.
}
/*-------------------------------------
P2.0 is lo. Set P0.0 hi. Read clock.
-------------------------------------*/
P0.0 = 1;
timer_tick = read_100hz_clock ();
/*-------------------------------------
Wait for 5 minutes. If P2.0 goes hi,
restart loop.
-------------------------------------*/
while (calc_time_diff (timer_tick) < (5UL * 60UL * 100UL))
{
if (P2.0)
goto RESET_LOOP;
}
/*-------------------------------------
Set P0.0 lo and P0.1 hi. Read clock.
-------------------------------------*/
P0.0 = 0;
P0.1 = 1;
timer_tick = read_100hz_clock ();
/*-------------------------------------
Wait for 4 seconds. If P2.0 goes hi,
restart loop.
-------------------------------------*/
while (calc_time_diff (timer_tick) < (4UL * 100UL))
{
if (P2.0)
goto RESET_LOOP;
}
/*-------------------------------------
Set P0.1 lo and P0.0 hi.
-------------------------------------*/
P0.1 = 0;
P0.0 = 1;
/*** OK - Now What??? Exit??? ***/
}
}
Of course, you'll have to write a timer-tick routine for the 100Hz clock and another routine to calculate the difference between the current timer tick and a previous timer tick. Jon |
| Topic | Author | Date |
| Need some expert help on a timing issue | 01/01/70 00:00 | |
| RE: Need some expert help on a timing issue | 01/01/70 00:00 | |
| RE: rtc example decrementing variables | 01/01/70 00:00 | |
| RE: Need some expert help on a timing is | 01/01/70 00:00 | |
RE: Need some expert help on a timing issue | 01/01/70 00:00 |



