|
#include"reg52.h"
sbit PWM=P1^0;
void main()
{
TMOD=0x01;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
EA=1;
ET0=1;
TR0=1;
while(1);
}
void T0_time(void) interrupt 1
{
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
if(PWM)
PWM=0;
else
PWM=1;
}
#include"reg52.h"
#define uint unsigned int
sbit PWM=P1^0;
int NUM=1000;
void main()
{
TMOD=0x01;
TH0=(65536-NUM)/256;
TL0=(65536-NUM)%256;
EA=1;
ET0=1;
TR0=1;
while(1);
}
void T0_time(void) interrupt 1
{
TH0=(65536-NUM)/256;
TL0=(65536-NUM)%256;
if(PWM)
PWM=0;
else
PWM=1;
}
上面兩個程序有什么不同,為什么步進(jìn)電機(jī)轉(zhuǎn)速不同?
|
|