

        /* delay for number of seconds requested */

        /* 2 MHz clock input                            */
        /*      divided by 100  (countdown value)       */
        /*      divided by 200  (prescaler value)       */
        /*      divided by 100  (time value multiplier) */
        /* yields counter in increments of one second ! */


#include "mfp_defs.h"           /* MFP address definitions */
#include "mfp_macs.h"           /* MFP macro definitions */

#define COUNTDOWN     100       /* countdown value */
#define DIV_200         7       /* prescaler 200 indicator */
#define TIME_MULT     100       /* input time multiplier */
#define TIMER_B         0       /* timer B en/disable, bit 0 */


delay(seconds)
int seconds;
{
        extern long stimer;             /* global counter */

        stimer = (long)0;               /* zero the counter */

        REGVAL(TBDR) = COUNTDOWN;       /* init the down counter */
        REGVAL(TBCR) = DIV_200;         /* prescaler div 200 */
        BIT_SET(IERA,TIMER_B);          /* enable timer B interrupt */
        seconds = seconds * TIME_MULT;  /* scale the time value */

                                        /* loop until time expired */
        while (stimer < seconds)        /* (stimer is incremented by */
                ;                       /*    an interrupt handler) */

        BIT_CLR(IERA,TIMER_B);          /* disable timer B interrupt */
        REGVAL(TBCR) = 0;               /* stop the timer */
}



