home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / util / setfreq.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  447 b   |  19 lines

  1. /*
  2.  *    setfreq -- sets PC's tone generator to run
  3.  *    continuously at the specified frequency
  4.  */
  5.  
  6. #include <conio.h>
  7. #include <local\timer.h>
  8.  
  9. void
  10. setfreq(f)
  11. unsigned f;    /* frequency in Hertz (approximate) */
  12. {
  13.     unsigned divisor = TIMER_CLK / f;
  14.  
  15.     outp(TIMER_CTRL, TIMER_PREP);        /* prepare timer */
  16.     outp(TIMER_COUNT, (divisor & 0xFF));    /* low byte of divisor */
  17.     outp(TIMER_COUNT, (divisor >> 8));    /* high byte of divisor */
  18. }
  19.