本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
复制代码- #include <reg52.h>
- #include <intrins.h>
- #define uint unsigned int
- #define uchar unsigned char
- uchar code table1[12]={0x28,0x7E,0xa2,0x62,0x74,0x61,0x21,0x7A,0x20,0x60,0x00,0xff};
- uchar code table2[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
- /**********************************************************
- 50US 延时子函数
- **********************************************************/
- void delay_50us(uint t){
- uchar j;
- for(;t>0;t--)
- for(j=19;j>0;j--);
- }
- /**********************************************************
- 50MS 延时子函数
- **********************************************************/
- void delay_50ms(uint t){
- uint j;
- for(;t>0;t--)
- for(j=6245;j>0;j--);
- }
- uchar num_0,num_1,num_2,num_3,tmp,i;
- uchar buf[8]={0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28};
- sbit int_1=P3^3;
- void main(void){
- TMOD=0x11;
- ET0=1;//定时器0开关
- ET1=1;
- TR0=1;//
- TR1=1;
- IT0=1;
- EX0=1;
- IT1=1;
- EX1=1;
- EA = 1;
- while (1){
- for(i=0;i<8;i++){
- P0=buf[i];
- P2=table2[i];
- delay_50us(20);
- }
- }
- }
- void procBuf(void){
- buf[0]=table1[num_0/10];
- buf[1]=table1[num_0%10];
- buf[2]=table1[num_1/10];
- buf[3]=table1[num_1%10];
- buf[4]=table1[num_2/10];
- buf[5]=table1[num_2%10];
- buf[6]=table1[num_3/10];
- buf[7]=table1[num_3%10];
- }
- void int0(void) interrupt 0{
- num_0++;
- if(num_0==100){
- num_0=0;
- }
- procBuf();
- }
- void timer0(void) interrupt 1 {
- TH0 = (65536-10000)/256;
- TL0 = (65536-10000)%256;
- if(++num_1==100){
- num_1=0;
- }
- procBuf();
- }
- void int1(void) interrupt 2{
- num_2++;
- if(num_2==100){
- num_2=0;
- }
- procBuf();
- }
- void timer1(void) interrupt 3 {
- TH1 = (65536-50000)/256;
- TL1 = (65536-50000)%256;
- tmp++;
- if(tmp==20){
- tmp=0;
- int_1=~int_1;
- if(++num_3==100){
- num_3=0;
- }
- procBuf();
- }
- }
复制代码 |