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

📄 timer.c

📁 Senbo公司dos下用于控制A/D及IO的驱动程序,用于cdt800扩展板上,广泛用于嵌入式工业控制领域.
💻 C
字号:
/*
   C language header file for sample programs for the CTD800.

   Science & Technology CO.,LTD.
   W2-B5 Shenzhen High-Tech Industrial Park,ShenZhen,GuangDong,P.R.C.

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

   Compiler: Turbo C (r) version 1.0, 2.0
	     Turbo C++ (r) version 1.0
	     Borland C++ (r) version 2.0, 3.0

   Last update: February 23, 2002

   DESCRIPTION
   ~~~~~~~~~~~
   Sample program that demonstrates how to program the 9513 counter/timer
   on the CDT800. First the counter mode register muse be set to indicate
   the desired operating characteristics of the counter, such as gating
   level and type,count direction and type,and output type. the next step
   is to load the appropriate data into the counter's load and hold register.
   the final step are to load the data into the counter's count register
   and to "arm",or enable the counter. Any of the counters be internally
   concatenaed. And an continuous square wave be generated form any of
   the counters.

*/

#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include "cdt800.c"

void main()
{
	int BA,chip,channel;

	 BA=0x300;
	 chip=0;
	 channel=1;

	 clrscr();

	 InitializeBoardSettings(BA);     /*  Set baseaddress   */
	 Master_Reset(chip);              /*  Duplicate the action the power-on reset circuitry  */
	 WriteData(0xd0b0,MM_Reg,chip);   /*  Program master mode register  */

	 WriteData(0x8b25,COUNTER1_MODE,chip);     /*  Program counter mode register  */
	 WriteData(10,COUNTER1_LOAD,chip);         /*  Load initial data into Load register  */

	 WriteData(0x8025,COUNTER2_MODE,chip);     /*  Program counter mode register  */
	 WriteData(10,COUNTER2_LOAD,chip);         /*  Load initial data into Load register  */

	 WriteData(0x8025,COUNTER3_MODE,chip);     /*  Program counter mode register  */
	 WriteData(10,COUNTER3_LOAD,chip);         /*  Load initial data into Load register  */

	 WriteData(0x8025,COUNTER4_MODE,chip);     /*  Program counter mode register  */
	 WriteData(10,COUNTER4_LOAD,chip);         /*  Load initial data into Load register  */

	 WriteData(0x8025,COUNTER5_MODE,chip);     /*  Program counter mode register  */
	 WriteData(10,COUNTER5_LOAD,chip);         /*  Load initial data into Load register  */

	 LOAD_COUNTER(channel,chip);      /*    Load initial data into Hold register  */
	 ARM(channel,chip);            /*   lssue Load and Arm command for counter  */

	 LOAD_COUNTER(channel+1,chip);        /*  Load initial data into Hold register  */
	 ARM(channel+1,chip);         /*  lssue Load and Arm command for counter  */

	 LOAD_COUNTER(channel+2,chip);        /*  Load initial data into Hold register  */
	 ARM(channel+2,chip);         /*  lssue Load and Arm command for counter  */

	 LOAD_COUNTER(channel+3,chip);        /*  Load initial data into Hold register  */
	 ARM(channel+3,chip);         /*  lssue Load and Arm command for counter  */

	 LOAD_COUNTER(channel+4,chip);        /*  Load initial data into Hold register  */
	 ARM(channel+4,chip);         /*  lssue Load and Arm command for counter  */

	 printf(" Any of the counters be internally concatenated.\n");
	 printf(" An continuous square wave be generated form any of");
	 printf(" the counters.\n ");
	 printf("Press any key to quit...");
	 while(TRUE)
	 {
	  if(kbhit())  break;
	 }
}

⌨️ 快捷键说明

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