如题 ,求大神帮忙修改,原想法是从1到60计数,现在个位数能正常,但十位数就是一闪而过,从闪过的数字看是想要的,但是现在怎么修改一下,不要闪,能停留到下个数更新
单片机源程序如下:
- #include "stc15.h"
- #define uchar unsigned char
- #define uint unsigned int
- #define SECOND 100
- uchar tab[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //定义共阳极字段码表(1-9-0)
- uint count=0;
- uint jishu=0;
- uint shiwei;
- uint gewei;
- sbit L1=P3^5;
- sbit L2=P3^6;
- sbit L3=P3^7;
- sbit miao1=P4^0;
- sbit miao2=P4^1;
- sbit fen1=P4^2;
- sbit fen2=P4^3;
- sbit shi1=P4^4;
- sbit shi2=P4^5;
- struct time{
- uchar hour;
- uchar min;
- uchar sec;
- };
- struct time clocktime _at_ 0x30;
- /***********************************延时函数*********************************************/
- void delay(uchar s){
- uchar k,z;
- for(k=0;k<s;k++)
- for(z=110;z>0;z--);
- }
- /************************************T0中断函数*****************************************/
- timer0() interrupt 1 using 2{
- TH0=0xd8;
- TL0=0xf0;
- if(++count == SECOND){
- shiwei=jishu/10;
- gewei=jishu%10;
- if(shiwei>=1){
- miao1=1;
- miao2=0;
- P2=tab[shiwei];
- delay(1000);
- miao2=1;
- miao1=0;
- P2=tab[gewei];
- delay(1000);
- }
- else{
- miao1=0;
- P2=tab[gewei];
- // delay(10);
- }
- jishu=jishu+1;
-
- count=0;
- L1=~L1;
-
- if(++clocktime.sec == 60){
- clocktime.sec=0;L2=~L2;
- if(++clocktime.min==60){
- clocktime.min=0;L3=~L3;
- if(++clocktime.hour==24){
- clocktime.hour=0;P3=0x00;
- }
- }
- }
- }
- }
- /************************************主函数*********************************************/
- void main(){
- TMOD=0x01;
- TH0=0xd8;TL0=0xf0;
- IE=0x82;TR0=1;
- while(1)
- {
- }
-
- }
复制代码
|