驱动六路电机 开关和走动 因为要驱动6个电机 所以不能控制一个电机直接关掉ET0 所以想用flag来当中断开关
#include
typedef unsigned char BYTE;
typedef unsigned int WORD;
BYTE flag1;
BYTE cache,count;
sbit DIR=P0^5;
//sbit SLP=P1^0;
sbit flag = P2^7;
sbit STEP=P0^4;
sbit EN = P0^0;
sbit M1 = P0^1;
sbit M2 = P0^2;
sbit M3 = P0^3;
//sbit EN=P1^3;
void Timer0Init(void) //100微秒@11.0592MHz
{
AUXR |= 0x80; //定时器时钟1T模式
TMOD &= 0xF0; //设置定时器模式
TL0 = 0xAE; //设置定时初值
TH0 = 0xFB; //设置定时初值
TF0 = 0; //清除TF0标志
TR0 = 1; //定时器0开始计时
EA=1;
// ET0=1;
}
void UartInit(void) /