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

📄 fifo.c

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

	FILE NAME: FIFO.C

	FILE DESCRIPTION: FIFO (FIFO test)

     Sample program that demonstrates how to use the on-board FIFO buffer.

	 Sample program that demonstrates how to acquire data at a specified
	 frequency until the FIFO is full. After the sampling period is over,
	 the data is displayed on the screen.

	PROJECT NAME: FIFO (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.
#define CHANNEL      0                 // A/D channel.
#define GAIN         0                 // Gain.
#define SE_DIFF 		0                 // Single-ended.
#define RATE         1000.0            // Sampling rate in [Hz].
#define ADSLOPE      (65536.0/20.0)    // Number Bits divided by AD Range.

double Actual_PACER_RATE;

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

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

void SetProgramScreen(void)
{
  clrscr();

  // Print header and footer.
  gotoxy( 1, 1); cprintf(TitleString6430());
  gotoxy(45, 1); cprintf("Conversion until FIFO is full");
  gotoxy( 1,25); cprintf("Press any key to exit. . .");

  window(1, 3, 80, 23);
  gotoxy(20, 8); cprintf("Sampling Channel %d at %0.2f Hz.", CHANNEL + 1, Actual_PACER_RATE);
  gotoxy(30,12); cprintf("Please wait!");
} //SetProgramScreen


int main(void)
{
  float            Data;               // Store acquired data
  unsigned         i;
  int              ADData;



  SetBaseAddress(BASE_ADDRESS);
  InitBoard6430();                         // Board initializing
  Actual_PACER_RATE = SetPacerClock6430(RATE);	// Programing the timer.

  SetProgramScreen();


  SetChannelGain6430(CHANNEL, GAIN, SE_DIFF); // Set channel and gain.
  SetStartTrigger6430(0);              // Set Start Trigger to Software.
  SetStopTrigger6430(0);               // Set Stop Trigger to Software.
  SetConversionSelect6430(1);          // Set Conversion to Pacer clock.
  ClearADFIFO6430();                   // Clear FIFO.
  StartConversion6430();               // Start conversion.

  while ( !IsADHalted6430() && ( !kbhit() )) ;
													// Wait until FIFO is full.
  if (kbhit()) getch();                // Get character, if pressed.

  // Display data to the screen.
  clrscr();
  i = 0;
  while (!IsADFIFOEmpty6430()) {       // Read Until FIFO Empty.
	 ADData = ReadADData6430();         // Read acquired data.
	 Data = ADData / ADSLOPE;           // Convert AD data to volts.
	 cprintf("%10.3f", Data);           // Display data.
	 i++;                               // Increment sample index.
  } //while

  // Display size of the FIFO buffer.
  //----------------------------------
  gotoxy( 1,21); cprintf("Your FIFO contained %d samples of data.", i);
  getch();                             // Wait until any key is pressed.

  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 + -