2 u010271762 u010271762 于 2013.06.21 18:01 提问

单片机L297 L298 驱动步进电机程序 帮忙解答 分析

#include
#define uchar unsigned char
#define uint unsigned int

sbit clock=P1^2;
sbit cw=P1^0;
sbit half=P1^3;
sbit control=P1^4;

uint MA=0,MB=0;//4Hhz的频率
uint SpeedA=25;//50%占空比
uint SpeedB=25;

void main(void)
{

cw=1;
clock=1;
half=1;
control=1;
TH0 = 0xEC;
TL0 = 0x78;

TMOD = 0x01;
TR0 = 1;
ET0 = 1;
EA  = 1;      
while(1){}

}

void time0_int() interrupt 1
{
TR0=0;

TH0=0xEC;
TL0=0x78;
MA++;

if(MA< SpeedA){
clock = 1;
}
else clock = 0;
if(MA == 50){
MA = 0;
}
TR0 = 1;
}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!