home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s300 / 1.ddi / CHAP2 / TMR1TEST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-02  |  2.1 KB  |  78 lines

  1. /***********************************************************************
  2.  
  3. FILE
  4.     timeintc.c  -  timer demo program using time1.c
  5.  
  6. SYNOPSIS
  7.     masm timeinta /ml;
  8.     cl /Gs /c time1.c
  9.     cl timeintc.c setalarm.c time1 timeinta
  10.  
  11. REMARKS
  12.     Prints the seconds for 10 seconds.  DOS's time keeping function is
  13.     temporarily suspended, but will be restored at the end of the test.
  14.  
  15.     This program sets the PC's system clock to tick at 50 ms intervals,
  16.     20 interrupts per second through init_tmr().
  17.  
  18. LAST UPDATE
  19.     18 January 1988
  20.  
  21.     Copyright(c) 1987-1988  D.M. Auslander and C.H. Tham
  22.  
  23. ***********************************************************************/
  24.  
  25. /***********************************************************************
  26.                             I M P O R T S
  27. ***********************************************************************/
  28.  
  29. #include <stdio.h>
  30.  
  31. #include "envir.h"
  32. #include "time1.h"
  33.  
  34.  
  35. /***********************************************************************
  36.                        P R I V A T E    D A T A
  37. ***********************************************************************/
  38.  
  39. static int tick = 0;            /* count of interrupts */
  40. static int time = 0;            /* time in seconds */
  41. static int flag = 0;            /* flag each 1 second period */
  42.  
  43.  
  44. /***********************************************************************
  45.                            R O U T I N E S
  46. /***********************************************************************
  47.  
  48. /*----------------------------------------------------------------------
  49. PROCEDURE
  50.     MAIN
  51.  
  52. REMARKS
  53.  
  54. LAST UPDATE
  55.     17 September 1987
  56. ----------------------------------------------------------------------*/
  57.  
  58. main()
  59. {
  60.  
  61.     init_tmr(50L);          /* initialize timer, 50 ms per tick */
  62.  
  63.     while (time < 10)               /* not 10 seconds yet */
  64.     {
  65.         settimer(1000L);            /* set for 1 second */
  66.  
  67.         while (!timeup())           /* wait */
  68.             ;
  69.  
  70.         printf("%2d\n", ++time);    /* print seconds */
  71.     }
  72.  
  73.     rstr_tmr();         /* restore timer system */
  74.  
  75. }
  76.  
  77.  
  78.