|
看到這類(lèi)資料比較少,拿去學(xué)習(xí)使用
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
運(yùn)行圖.jpg (1.05 MB, 下載次數(shù): 52)
下載附件
2023-6-3 23:20 上傳
單片機(jī)源程序如下:
- #include <reg52.h>
- #define uchar unsigned char
- #define uint unsigned int
- #define uLint unsigned long int
- void delayMs(uint x);
- uchar countInterrupt=0;
- sbit P3_3=P3^3;
- uchar code seg_table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
- uint displayTable[]={0,0,0,0,0,0,0,0};
- void main(void)
- {
- uchar cBitCode,i;
- uLint count;
- ET1=1;
- EA=1;
-
- TH1=0;
- TL1=0;
- TMOD=0x90;//gate=1,method 1
-
- while(P3_3==1);
-
- TR1=1;
- while(P3_3==0);
- while(P3_3==1);
- TR1=0;
-
- count=(uLint)TH1*256+TL1;
- count=count*2;
- count=(uLint)countInterrupt*65536*2+count;
- displayTable[0]=count/10000000;
- displayTable[1]=count%10000000/1000000;
- displayTable[2]=count%1000000/100000;
- displayTable[3]=count%100000/10000;
- displayTable[4]=count%10000/1000;
- displayTable[5]=count%1000/100;
- displayTable[6]=count%100/10;
- displayTable[7]=count%10;
-
- while(1)
- {
- cBitCode=0x01;
- for(i=0;i<8;i++)
- {
- P2= ~ seg_table[displayTable[i]];
- P1= ~cBitCode;
- delayMs(1);
- P1=0xFF;
- cBitCode<<=1;
- }
- }
- }
- void delayMs(uint x)
- {
- uchar j;
- while(x--)
- {
- for(j=0;j<125;j++)
- ;
- }
- }
- void timer1_src(void) interrupt 3
- {
- countInterrupt++;
- }
復(fù)制代碼
Keil代碼與Proteus仿真下載:
仿真程序.7z
(76.68 KB, 下載次數(shù): 27)
2023-6-4 23:20 上傳
點(diǎn)擊文件名下載附件
原理仿真圖 下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|