標題:
利用at89c51設(shè)計電子秒表 程序有兩個錯誤求改
[打印本頁]
作者:
t997914536
時間:
2017-8-30 09:36
標題:
利用at89c51設(shè)計電子秒表 程序有兩個錯誤求改
#include<reg51.h>
unsigned int table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned int place[]={0x1f,0x2f,0x37,0x3b,0x3d,0x3e};
unsigned int doc[]={0x3f,0x3f,0x3f,0x3f,0x3f,0x3f};
unsigned char t=0;
unsigned int count[6]={0,0,0,0,0,0};
unsigned int k1_count=0;
void reset();
void initDoc();
void initCount();
void suspend();
void init();
void timerRun();
void t1(void);
void delay1ms(void)
{
unsigned char a,b;
for(a=199;a>0;a--)
for(b=1;b>0;b--);
}
void initDoc()
{
unsigned int i;
for(i=0;i<6;i++)
doc[i]=table[0];
}
void initCount()
{
unsigned int i;
for(i=0;i<6;i++)
count[i]=0;
}
void display()
{
unsigned int i;
for(i=0;i<6;i++)
{
P0=doc[i];
P2=place[i];
delay1ms();
delay1ms();
P0=0x00;
delay1ms();
}
}
void run()
{
unsigned char i;
if(count[0]<9)
count[0]++;
else
{
count[0]=0;
count[1]++;
if(count[1]>9)
{
count[1]=0;
count[2]++;
if(count[2]>9)
{
count[2]=0;
count[3]++;
if(count[3]>6)
{
count[3]=0;
count[4]++;
if(count[4]>9)
{
count[4]=0;
count[5]++;
if(count[5]>6)
count[5]=0;
}
}
}
}
}
for(i=0;i<6;i++)
{
doc[i]=table[count[i]];
}
}
void t1(void) interrupt 3
{
TH1=0xd8;
TL1=0xf0;;
run();
}
void int_int0(void) interrupt 0
{
if(k1_count==0)
k1_count=1;
else
k1_count=0;
}
void int_int1(void) interrupt 2
{
k1_count=2;
}
void timerRun()
{
P1=0x02;
TMOD=0x10;
TR1=1;
ET1=1;
EA=1;
while(k1_count==1)
{
display();
}
if(k1_count==0)
suspend();
if(k1_count==2)
{
reset();
}
}
void init()
{
P1=0x01;
initdoc();
IT0=1;
EA=1;
EX0=1;
IT1=1;
EX1=1;
while(k1_count==0)
{
display();
}
if(k1_count==1)
{
timerRun();
}
}
void suspend()
{
P1=0x01;
TR1=0;
while(k1_count==0)
{
display();
}
if(k1_count==1)
{
timerRun();
}
else if(k1_count==2)
{
reset();
}
}
void reset()
{
P1=0x01;
TR1=0;
initcount();
IT0=1;
EA=1;
EX0=1;
IT1=1;
EX1=1;
k1_count=0;
while(k1_count==0)
{
display();
}
if(k1_count==1)
{
timerRun();
}
if(k1_count==2)
reset();
}
void main()
{
init();
}
作者:
cjjcjj1
時間:
2017-8-30 13:01
提示:
作者被禁止或刪除 內(nèi)容自動屏蔽
作者:
853282537
時間:
2017-8-30 14:10
什么錯誤也沒給出來
作者:
853282537
時間:
2017-8-30 14:11
什么錯誤也沒給出來 把void main() 改成main()試試
作者:
ahshmj
時間:
2017-8-30 15:34
出現(xiàn)什么錯誤?這么個程序讓人一點點琢磨?沒有重點的一句一句的研究?誰有那個功夫?
作者:
zl2168
時間:
2017-8-30 16:27
ahshmj 發(fā)表于 2017-8-30 15:34
出現(xiàn)什么錯誤?這么個程序讓人一點點琢磨?沒有重點的一句一句的研究?誰有那個功夫?
冗長的程序,一句一句的研究?誰有那個功夫?
作者:
cjjcjj1
時間:
2017-8-30 16:31
提示:
作者被禁止或刪除 內(nèi)容自動屏蔽
作者:
yzwzfyz
時間:
2017-8-31 19:52
本帖最后由 yzwzfyz 于 2017-9-1 00:08 編輯
問者很初級,尚不懂得尊重師者。
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1