⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.c

📁 源代码PC104用户手册PC104用户手册PC104用户手册
💻 C
字号:
/*
  Science & Technology CO.,LTD.
  W2-B5 High-Tech Industrial Park, ShenZhen, GuangDong, P.R.C.

  Tel:   86-755-6544000
  Fax:   86-755-6549140
  Zip:   518057

  Board:       SF93A-0102
  Compiler:    Turbo C (r) version 1.0, 1.5, 2.0
		Turbo C++ (r) version 1.0
		Borland C++ (r) version 2.0, 3.0

  Last update: Feb 22, 2002

  DESCRIPTION
  ~~~~~~~~~~~
  Sample program demonstrating how to program the 71054 programmable interval
  timers (PITs) on the ADT600.  The user PIT is set to run at a specified
  rate and every time it finishes a cycle a global variable (i) is
  incremented.  The value of i is displayed on the screen.  The program
  uses a polling technique for accessing if the PIT has completed a cycle.
  This can be a perilous technique for rates faster than 50 - 100 Hz.  Users
  who wish to see how the PIT can generate interrupts should examine the
  INTRPTS.C file.


  NOTES
  ~~~~~
  You must change the first line in the main function to reflect the
  base address for your ADT600.

*/

#include <dos.h>
#include <conio.h>

#include "ADT600.h"
#include "ADT600.inc"

char C;
unsigned char i;
char ExitProgram;

float ClockRate;

/**********

  ProgramTitle

  The ProgramTitle function displays a description of the program on the
  screen.

**********/

void ProgramTitle(char St[])
{
 gotoxy(1,1); clreol();
 cprintf("ADT600  Sample Program");
 gotoxy(80 - strlen(St), 1);
 cprintf(St);
}


void main(void)
{
 InitializeBoardSettings(0x300, 10.0, BIPOLAR);  /* Set base address and volt
						  range */

 clrscr();
 ProgramTitle("Timer Example");
 gotoxy(25, 12);
 cprintf("Elapsed time:     0.0  seconds");

 ResetBoard();                           /* Reset the board */

 ClockRate = 10.0;
 SetUserClock(ClockRate);              /* Set a clock rate */

 ExitProgram = FALSE;
 i = 0;
 while (ExitProgram == FALSE)
  {
   gotoxy(1,25);
   cprintf("Press any key to START timer (ESC to quit). . .");
   C = getch();
   if (C != 27)
    {
     gotoxy(1,25);
     cprintf("Press any key to STOP timer  (ESC to quit). . .");

     while (kbhit() == 0)
      {
       while (ClockDone(2) == FALSE);
        /* Wait until clock done with cycle */

       gotoxy(40, 12);
       cprintf("%6.2f", (i / ClockRate));       /* Display count */
       i++;                                   /* Increment count */

       while (ClockDone(2) == TRUE);
        /* Wait until clock restarts cycle.  */
      }

     C = getch();

     if (C == 27)
      ExitProgram = TRUE;
    }
   else
    ExitProgram = TRUE;
  }

 clrscr();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -