#include<stdio.h>
#include<dos.h>
#include<conio.h>
#define PA 0X0280 //端口
#define PB 0X0282
#define PC 0X0284
#define CR 0X0286
#define CW 0X90 //PA:输入,PB:输出,PC:输出
#define CWP0 0X02 //保持 表9.1
#define CWP1 0X03 //正转 同上
#define CCWP0 0X06 //保持
#define CCWP0 0X07 //反转
#define MOFF 0X00 //电机停止
#define TIMEP 20 //适当的脉冲振幅
#define TIMER 250 //适当的脉冲间隔
void movcw(int port, int tb);
void movccw(int port, int tc);
void motoff(int port);
void walt(int times); //函数声明
void main(void)
{
int countb; //计数变量
outp(CR, CW); //8255初始化
outp(PB, CWP0); //电机启动准备
countb = TIMEP; //脉冲间隔
while (!kbhit()) //有按键时返回
movcw(PB, countb); //运转
motoff(PB); //停止
}
void movcw(int port, int tb) //正转函数
{
outp(port,CWP1); wait(TIMEP);
outp(port, CWP0); wait(tb);
}
void movcw(int port, int tc) //反转函数
{
outp(port, CWP1); wait(TIMEP);
outp(port, CWP0); wait(tc);
}
void motoff(int port) //停止函数
{
outp(port, MOFF);
}
void wait(int times) //等待函数
{
int i; //注:因为time已在库中定义故使用其它名字
for (i = 0; i < times; i++)
printf("" ;
}
为什么会报错
![小程序出错 哪位大神给讲讲,谢谢!!!!!!!!!!!!]()
截图00.png |