標(biāo)題: 有程序,但怎么寫程序流程圖?求方法 [打印本頁(yè)]
作者: yanyyh 時(shí)間: 2019-5-12 22:42
標(biāo)題: 有程序,但怎么寫程序流程圖?求方法
1.PNG (61.34 KB, 下載次數(shù): 20)
下載附件
八路搶答器 原理圖
2019-5-12 22:43 上傳
#include "reg51.h"
#include "intrins.h"
unsigned char code SMG_CODE[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
//共陰數(shù)碼管“0”“1”“2”“3”“4”“5”“6”“7”“8”“9”
sbit AnJan_1=P1^0;
sbit AnJan_2=P1^1;
sbit AnJan_3=P1^2;
sbit AnJan_4=P1^3;
sbit AnJan_5=P1^4;
sbit AnJan_6=P1^5;
sbit AnJan_7=P1^6;
sbit AnJan_8=P1^7;
sbit start=P3^1; //開始鍵
sbit reset=P3^2; //復(fù)位鍵
sbit BZ=P3^0; //蜂鳴器
char i,a,state=0;
void Yanshi10ms(unsigned int m) //誤差0us
{
unsigned char j,h;
for(;m>0;m--)
for(h=38;h>0;h--)
for(j=130;j>0;j--);
}
void main()
{
BZ=1;
TMOD=0x01; //定時(shí)器0方式1
TH1=(65536-50000)/256; //恢復(fù)定時(shí)器1初值
TL1=(65536-50000)%256;
EA=1;
P0=0x00;
while (1)
{
while(state==0)
{
if(start==0)
{
Yanshi10ms(1);
if(start==0)
{
P0 = 0x40;
BZ=0;
ET1=1;TR1=1;
a=0;
state=1;
while(start==0);
}
}
}
while(state==1)
{
if(AnJan_1==0)
{
P0 = SMG_CODE[1];
BZ=0;
ET1=1;TR1=1;
state=2;
}
if(AnJan_2==0)
{
P0 = SMG_CODE[2];
BZ=0;
ET1=1;TR1=1;
state=2;
}
if(AnJan_3==0)
{
P0 = SMG_CODE[3];
BZ=0;
ET1=1;TR1=1;
state=2;
}
if(AnJan_4==0)
{
P0 = SMG_CODE[4];
BZ=0;
ET1=1;TR1=1;
state=2;
}
if(AnJan_5==0)
{
P0 = SMG_CODE[5];
BZ=0;
ET1=1;TR1=1;
state=2;
}
if(AnJan_6==0)
{
P0 = SMG_CODE[6];
BZ=0;
ET1=1;TR1=1;
state=2;
}
if(AnJan_7==0)
{
P0 = SMG_CODE[7];
BZ=0;
ET1=1;TR1=1;
state=2;
}
if(AnJan_8==0)
{
P0 = SMG_CODE[8];
BZ=0;
ET1=1;TR1=1;
state=2;
}
if(reset==0)
{
state=0;
P0=SMG_CODE[17];
BZ=1;
break;
}
}
while(state==2)
{
if(reset==0)
{
state=0;
BZ=1;
P0=SMG_CODE[17];
break;
}
}
}
}
void Dingshiqi1() interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
a++;
if(a>=20)
{
ET1=0;TR1=0;
a=0;
BZ=1;
}
}
作者: yzwzfyz 時(shí)間: 2019-5-13 08:11
這是個(gè)逆向工程,考你的程序閱讀能力和理解能力,通常必須配合硬件資料!
作者: 17722827926 時(shí)間: 2019-5-13 09:07
先理清代碼背后的數(shù)學(xué)邏輯關(guān)系,然后看每段功能代碼之間的關(guān)系,分清先后順序,就可以寫出來了
作者: 藍(lán)廊坊市 時(shí)間: 2019-5-13 09:52
理清程序怎么運(yùn)行的照著畫就行
作者: zhujian1234 時(shí)間: 2019-5-13 20:33
有自動(dòng)生成流程圖的軟件,AutoFlowchart,了解一下。
歡迎光臨 (http://www.torrancerestoration.com/bbs/) |
Powered by Discuz! X3.1 |