利用中断实现每500毫秒接收一次数据
//调用DOS下的中断。
//DOS的时钟中断 int 21H AH=0x1C 每秒产生18.2次中断
//该程序时间间隔为550毫秒 可以由count的值算出。
#include
#include
#include
#define INTR 0X1C //0x1c为时钟中断
#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
void interrupt ( *oldhandler)(__CPPARGS);
int count=0;
int a=0,b=0;
strUCt time t;
void interrupt handler(__CPPARGS) // 执行DOS中断时调用的程序
{
count++;
if(count==10)
{ gettime(&t);
b=t.ti_hund;
printf("(2) %d
",b);