发表于:2005-05-02 18:37:00
1楼
这个是源程序,但是编译通不过,错误信息是:
error C2146 missing ';' before identifier '_beginthread'
#include"windows.h"
#include<stdio.h>
#include<process.h>
#include"8133.h"
//#include"stdlib.h"
//#include"conio.h"
//#include"stddef.h"
#define CNO 0
long Position=0;
U16 pls_N=0,pls_NM1=0;
int dPLS;
HANDLE hEventarray[2];
U16 Status,IndexData;
U16 card_no=0,bn;
HANDLE hEvent[2],hThread1;
U16 event_count=0;
U16 new_value, old_value=65536;
void ProcessInterrupt(void *ss)
{
U16 mode;
do{
WaitForSingleObject(hEvent[0],20/*INFINITE*/);
W_8133_Read_Cnt(CNO,1,&pls_N);//读计数器的内容
dPLS=(int)pls_N-(int)pls_NM1;//求增量
Position+=dPLS;//增量累计之后就是位置数据
pls_NM1=pls_N;
ResetEvent(hEventarray[1]);
}while(1);
_endthread();
}
void main()
{
W_8133_Initial(CNO);//初始化计数器
W_8133_Software_Reset(CNO);//重置计数器
Sleep(1);
W_8133_ModeSelect(CNO,0x42);//set control mode for index mode, CNT1 at CW/CCW mdoe;
W_8133_Set_Int0Perd(CNO,0x07d0);//set Period of INT0 is 200us
W_8133_CLR_IRQ0(CNO);
W_8133_CLR_IRQ1(CNO);
W_8133_INT_Enable(CNO,hEventarray);
W_8133_Set_INT_Control(CNO,1,1)////**************???????
_beginthread(ProcessInterrupt,0,(void *)(ss++));////***************???????
//printf("The postion is %d",Position);
}