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

📄 timers.c

📁 rt采集卡dos下dm6430驱动源代码
💻 C
字号:
/***************************************************************************

	FILE NAME: TIMERS.C

	FILE DESCRIPTION: TIMERS (User Timer)

	 Sample program that demonstrates how to program the user timer.

	 Sample program demonstrating how to program the 8254 programmable
	 interval timers (PITs). Counter 0 is programmed to run at 200 Hz.
	 Counter 1 is used to count these pulses. The result is converted
	 into seconds and printed on the screen.

	PROJECT NAME: TIMERS (Part of DM6430 DOS Driver)

	DRIVER VERSION: 1.1

	COMPILER: Borland C++ 3.1

	TARGET: Real-Mode DOS

	Copyright 2003 RTD Embedded Technologies

***************************************************************************/

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

#include "drvr6430.h"
#include "dio5812.h"


/***************************************************************************
  Defines

  Change these constants to alter the program parameters.
****************************************************************************/
#define BASE_ADDRESS 768              // Base address of DM6430


/***************************************************************************
  SetProgramScreen()

  The SetProgramScreen() function initializes the screen.
****************************************************************************/

void SetProgramScreen(void)
{
  clrscr();

  // Print header and footer.
  gotoxy( 1, 1); cprintf(TitleString6430());
  gotoxy(50, 1); cprintf("Timer Example");
  gotoxy( 1,25); cprintf("Press any key to exit. . .");

  window(1, 3, 80, 23);
  gotoxy(25, 8); cprintf("Elapsed time:     0.0  seconds");
} //SetProgramScreen


int main(void)
{
  clrscr();
  SetProgramScreen();

  SetBaseAddress(BASE_ADDRESS);        // Set base address.
  InitBoard6430();                     // Board initializing.

  SelectTimerCounter6430(1);           // Select user T/C
  ClockMode6430(0,2);                  // Set Clock 0 to mode 2
  ClockMode6430(1,0);                  // Set Clock 1 to mode 0
  ClockDivisor6430(0,40000);           // Set Clock 0 Divider to 40,000
  ClockDivisor6430(1,0xFFFF);          // Set Clock 1 starting value

  while (!kbhit()) {                   // Run until any key pressed.

	gotoxy(40, 8);
	cprintf("%6.1f",  (float)(65535-ReadTimerCounter6430(1,1))/ 200.0 );
  } //while

  DoneTimer6430();                     // Shut down user timer.

  window(1,1,80,25);                   // Reset original screen coordinates,
  clrscr();                            // and clear the screen.
  return 0;
} //main

⌨️ 快捷键说明

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