仿真图
为啥把程序刷进去没反应
- #include<reg52.h>
- unsigned char code a[]={0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8,0x80, 0x90};
- unsigned char abuff[]={0xFF,0xFF,0XFF,0XFF,0XFF,0XFF};
- unsigned char sec=0; //记录秒数
- unsigned char i=0; //动态扫描索引
- unsigned char count=0; //记录中断次数 TF0=1为一次中断
- void main()
- {
- EA=1; //开启中断
- ET0=1; //开启定时器0中断
- TR0=1; //开启定时器0
- TMOD=0x01;
- TH0=0xFC;
- TL0=0x65;
- while(1)
- {
- if(count>=1000) // 中断1000次,即达到1s
- {
- count=0;
- sec++; //秒数加1
- abuff[0]=a[sec%10];
- abuff[1]=a[sec/10%10];
- abuff[2]=a[sec/100%10];
- abuff[3]=a[sec/1000%10];
- abuff[4]=a[sec/10000%10];
- abuff[5]=a[sec/100000%10];
- }
- }
- }
-
- void InterruptT0() interrupt 1 //interrupt为关键字,1表示定时器0中断
- {
- TH0=0xFC;
- TL0=0x65;
- count++;
- P1=0xFF; //显示消隐
- switch(i)
- {
- case 0: P2=0x01;i++;P1=abuff[0];break;
- case 1: P2=0x02;i++;P1=abuff[1];break;
- case 2: P2=0x40;i++;P1=abuff[1];break;
- case 3: P2=0x80;i++;P1=abuff[1];break;
- case 4: P2=0x10;i++;P1=abuff[1];break;
- case 5: P2=0x20;i=0;P1=abuff[1];break;
- default:break;
- }
- }
复制代码
|