对中断定时器一知半解, 抄袭了下面的程序, 怎么修改成能够修改成加速步进电机
#include <reg52.h>
unsigned char code F_Rotation[]={0x01,0x05,0x04,0x06,0x02,0x0a,0x08,0x09};
main()
{
TMOD |=0x01; //定时器设置 1ms in 12M crystal
IE= 0x82; //打开中断
ET0 = 1;
TR0=1;
while(1)
{
}
}
void Timer0(void) interrupt 1 using 1
{
static unsigned char Cnt;
TH0=(65536-55000)/256;
TL0=(65536-55000)%256;
if(Cnt<8) Cnt++;
else Cnt=0;
P3=F_Rotation[Cnt];
}
1、修改定时器的时间
void Timer0(void) interrupt 1 using 1
{
static unsigned char Cnt;
TH0=(65536-55000)/256;
TL0=(65536-55000)%256;
if(Cnt<8) Cnt++;
else Cnt=0;
P3=F_Rotation[Cnt];
}
2、修改那个8
void Timer0(void) interrupt 1 using 1
{
static unsigned char Cnt;
TH0=(65536-55000)/256;
TL0=(65536-55000)%256;
if(Cnt<8) Cnt++;
else Cnt=0;
P3=F_Rotation[Cnt];
}
你上你可以测试一下如果可以那最好
我个人不用C
不过感觉下面这个地方是不是要加上大括号?
if(Cnt<8) Cnt++;
else
{
Cnt=0;
P3=F_Rotation[Cnt];
}
2、修改那个8
void Timer0(void) interrupt 1 using 1
{
static unsigned char Cnt;
TH0=(65536-55000)/256;
TL0=(65536-55000)%256;
if(Cnt<8) Cnt++;
else Cnt=0;
P3=F_Rotation[Cnt];
}
你上你可以测试一下如果可以那最好
我个人不用C
不过感觉下面这个地方是不是要加上大括号?
if(Cnt<8) Cnt++;
else
{
Cnt=0;
P3=F_Rotation[Cnt];
}
1、修改定时器的时间
void Timer0(void) interrupt 1 using 1
{
static unsigned char Cnt;
TH0=(65536-55000)/256;
TL0=(65536-55000)%256;
if(Cnt<8) Cnt++;
else Cnt=0;
P3=F_Rotation[Cnt];
}
你上你可以测试一下如果可以那最好
我个人不用C
不过感觉下面这个地方是不是要加上大括号?
if(Cnt<8) Cnt++;
else
{
Cnt=0;
P3=F_Rotation[Cnt];
}
不用C?用什么?汇编?
欢迎光临 (http://www.51hei.com/bbs/) | Powered by Discuz! X3.1 |