對中斷定時器一知半解, 抄襲了下面的程序, 怎么修改成能夠修改成加速步進電機
#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://m.zg4o1577.cn/bbs/) | Powered by Discuz! X3.1 |