?? 836demo6.c
字號:
/*****************************************************************************
* *
* 836DEMO6.C - Example of PCL-836 counter card *
* Pulse generate (FOUT function) demo program *
* Advantech Co,.Ltd. 2/24/97 *
*****************************************************************************
*/
#include <dos.h>
#include <stdio.h>
#include <bios.h>
#include <conio.h>
#include <stdlib.h>
#include "..\driver.h"
void ShowErrorMessage(unsigned long ErrorCode);
void dis_main(void);
/*=============================================================*/
/* Main program */
/*=============================================================*/
main(void)
{
unsigned short usBaseAddress, usDeviceNumber;
unsigned short usCounter;
unsigned long retCode;
unsigned int keyin;
// default base address & device number
usBaseAddress = 0x240;
usDeviceNumber = 0x00;
// display demo program description
clrscr();
dis_main();
// Open device driver
retCode = DeviceOpen(usDeviceNumber, usBaseAddress);
if (retCode != 0L)
{
ShowErrorMessage(retCode);
return;
}
// initilize counter function
FreqOutStart(usDeviceNumber, 0, (float)200.0);
FreqOutStart(usDeviceNumber, 1, (float)1000.0);
FreqOutStart(usDeviceNumber, 2, (float)10000.0);
FreqOutStart(usDeviceNumber, 3, (float)100000.0);
FreqOutStart(usDeviceNumber, 4, (float)1000000.0);
FreqOutStart(usDeviceNumber, 5, (float)5000000.0);
while(1)
{
do
{
gotoxy(10,17);
printf("FOUT function is in progressing ......");
} while(!bioskey(1));
keyin = bioskey(0);
if((keyin &= 0x0ff) == 27)
break;
gotoxy(15,20);
printf(" Press ESC to ABORT, other key to CONTINUE !");
if((bioskey(0) & 0x0ff) == 27)
break;
}
for (usCounter = 0 ; usCounter < 6 ; usCounter++)
FreqOutReset(usDeviceNumber, usCounter);
DeviceClose(usDeviceNumber);
return;
}
/*=============================================================*/
/* display description */
/*=============================================================*/
void dis_main(void)
{
gotoxy(25,3);
printf("****** PCL836DEMO 6 ***** ");
gotoxy(10,5);
printf("The demo program uses square wave generator");
gotoxy(10,6);
printf("This Base Address is set to 0x240 and connect FOUT0 - FOUT5.");
gotoxy(10,8);
printf(" Please check wave generator:");
gotoxy(10,9);
printf(" <0> FOUT0 ---- 200 HZ ");
gotoxy(10,10);
printf(" <1> FOUT1 ---- 1K HZ");
gotoxy(10,11);
printf(" <2> FOUT2 ---- 10K HZ");
gotoxy(10,12);
printf(" <3> FOUT3 ---- 100K HZ");
gotoxy(10,13);
printf(" <4> FOUT4 ---- 1M HZ");
gotoxy(10,14);
printf(" <5> FOUT5 ---- 5M HZ");
}
/*=============================================================*/
/* show error message */
/*=============================================================*/
void ShowErrorMessage(unsigned long ErrorCode)
{
char szErrorMsg[10][80]=
{
{"DeviceNumber is out of range ,its range is from 0 to 9."},
{"Invalid Base Address."},
{"This DeviceNumber is in use !"},
{"Invalid Base Address, DeviceOpen must be called before any other functions."},
{"Illegal Channel"},
{"Illegal Input Param"},
{"The freqence of calling the function is too high."},
{"FOUT frequency is out of range "},
{"Invalid Port Channel"}
};
gotoxy(10,24);
if ((ErrorCode > (unsigned long)MaxErrorCode) || (ErrorCode == 0L))
printf("No Error");
else
printf("%s\n",&szErrorMsg[ErrorCode-1][0]);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -