发表于:2003-11-10 10:32:00
楼主
哪位大侠帮忙!?我现在需要在DOS下利用PCI7200来采集数据,设置count=2000,采用单次DMA方式,可是采集到的数据却只有100多个,返回的currentCount最多只有104,为什么?
是不是需要配置还是我的程序有问题?我是利用\dos_bc\samples\di_demo2.c例程改写的,只是将原来的输入_7200_do()去掉,然后由FPGA输出数据,采用I_req&I_ack握手方式,不知是否有问题?FPGA发出的I_req信号为3us,即使我将模式改为外部时钟触发,也不能获得我所需要的数据,不知道怎么办,希望高人指点,下面是我的源程序:
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <\sys\stat.h>
#include "acl.h"
#include "aclerr.h"
#include "std.h"
#include "video.h"
#include "key.h"
#include "7200.H"
#pragma(4)
#define ACL_TitleColor (WHITE | bgcolor(GREEN))
#define ACL_TextColor (WHITE | bgcolor(BLUE))
#define ACL_BkColor (BLUE | bgcolor(BLUE)) /* background color */
#define ACL_MsgColor (RED|INVERSE)
#define ACL_ProgColor (WHITE | bgcolor(BROWN))
#define DI_DB_COUNT 1000 /* double buffer count */
#define DI_SAMPLE_COUNT (DI_DB_COUNT * 2)
#define DI_DB_ENABLE 1 /* double duffer mode enable */
#define DI_DB_DISABLE 0 /* double duffer mode disable */
std_UByte *acl_Title = "****** PCI-7200 DI DEMO (continue DMA)";
std_UByte *acl_Copyright="Copyright (c) 1995-1999, ADLink Technology Inc. All rights reserved.";
std_UByte *msg1 = "Program : DI_DEMO3.C";
std_UByte *msg2 = "Function: continue read digital input data throught DMA (Bus Master)";
std_UByte *msg3 = " using double buffer mode to receive data";
U32 *diDmaDwPtr; /* double word boundary pointer */
U8 *charPtr;
U32 diDmaBuf[DI_SAMPLE_COUNT+1]; /* +1 for double word alignment adjusting */
U32 userBuf[DI_DB_COUNT];
Boolean clear_fifo=FALSE, disable_di=FALSE;
/*----------------------------------------------------------------------*/
void showMessage(std_UByte *msg)
{
video_ClearBox(24, 0, 24, 79, INVERSE);
video_CenterPutStr(24, msg, ACL_MsgColor);
}
/*----------------------------------------------------------------------*/
void main( void )
{
int i, j, h, handle, x1, y1, err, status, timerMode;
U32 readyCnt;
char tmpBuf[80];
Boolean readyFlag;
U16 c0, c1, c2;
U32 dest;
U8 irqNo; /* interrupt line number, assigned by system */
U16 baseAddr; /* base address, assigned by system */
U32 currentCount; /* current count of DMA read for DI */
U32 overrunCnt;
/*---------- PCI-7200 initial ------------------------------------------*/
if( (err =_7200_Initial(CARD_1, &baseAddr, &irqNo)) != ERR_NoError ) {
printf("No PCI-7200 card found !!\n");
exit(0);
}
/*----------------------------------------------------------------------*/
video_Initial();
video_CursorOff();
video_Box(VIDEO_SINGLE, 0, 0, 4, 79, ACL_TitleColor);
video_Box(VIDEO_DOUBLE, 5, 0, 23, 79, ACL_TextColor);
video_ClearBox(24, 0, 24, 79, INVERSE | BLUE);
sprintf(tmpBuf,"%s, Address = %X IRQ = %d ******", acl_Title, baseAddr, (unsigned char)irqNo);
video_CenterPutStr(1, tmpBuf, ACL_TitleColor);
video_CenterPutStr(3, acl_Copyright, ACL_TitleColor);
video_PutStr(6, 5, msg1, ACL_ProgColor);
video_PutStr(7, 5, msg2, ACL_ProgColor);
video_PutStr(8, 5, msg3, ACL_ProgColor);
showMessage(">>> Press any key to start the operation <<<");
getch();
/* double word alignment adjusting */
dest = ((U32) FP_SEG(diDmaBuf))*16 + FP_OFF(diDmaBuf);
charPtr = (char *) diDmaBuf;
diDmaDwPtr = (U32 *) (charPtr + (dest & 0x03L));
_7200_DblBufferMode(DI_DB_ENABLE);
getch();
/*;;;;;;;;;;;;;;;;;;;;; Setup the DMA for DI ;;;;;;;;;;;;;;;;;;;;;;;*/
if( _7200_DI_DMA_Start(DI_MODE_3, DI_SAMPLE_COUNT, diDmaDwPtr,
DI_WAITING, DI_RISING, clear_fifo, disable_di) != ERR_NoError) {
video_CursorOn();
video_ClearBox(24, 0, 24, 79, NORMAL);
video_PutSt