對(duì)中斷定時(shí)器一知半解, 抄襲了下面的程序, 怎么修改成能夠修改成加速步進(jìn)電機(jī)
#include <reg52.h>
unsigned char code F_Rotation[]={0x01,0x05,0x04,0x06,0x02,0x0a,0x08,0x09};
main()
{
TMOD |=0x01; //定時(shí)器設(shè)置 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、修改定時(shí)器的時(shí)間
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、修改那個(gè)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è)試一下如果可以那最好
我個(gè)人不用C
不過感覺下面這個(gè)地方是不是要加上大括號(hào)?
if(Cnt<8) Cnt++;
else
{
Cnt=0;
P3=F_Rotation[Cnt];
}
2、修改那個(gè)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è)試一下如果可以那最好
我個(gè)人不用C
不過感覺下面這個(gè)地方是不是要加上大括號(hào)?
if(Cnt<8) Cnt++;
else
{
Cnt=0;
P3=F_Rotation[Cnt];
}
1、修改定時(shí)器的時(shí)間
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è)試一下如果可以那最好
我個(gè)人不用C
不過感覺下面這個(gè)地方是不是要加上大括號(hào)?
if(Cnt<8) Cnt++;
else
{
Cnt=0;
P3=F_Rotation[Cnt];
}
不用C?用什么?匯編?
歡迎光臨 (http://www.torrancerestoration.com/bbs/) | Powered by Discuz! X3.1 |