|
如何在仿真软件上做到只显示后四位不显示前四位TAT
还有普中软件上串口调试助手怎么在发送出打完之后接受区就有刚刚打出的数字
自己的程序
- #include <reg51.h>
- #include<intrins.h>
- sbit key1=P1^4;
- sbit key2=P1^5;
- sbit OUTA=P2^2;
- sbit OUTB=P2^3;
- sbit OUTC=P2^4;
- unsigned char seg_code[30]={0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F,0X77,0X7C,0X39,0X5E,0X79,0X71,0X00,0X40};
- // 0 1 2 3 4 5 6 7 8 9 A B C D E F - ?????
- int flag1s=0;
- int ge=0,shi=0;bai=3,qian=4;
- int counter1=0;
- //int led[8]={3,2,4,0,9,1,0,2};
- int led[8]={2,0,1,9,0,4,2,3}; //????
- int hour=16,min=59,sec=55;
- void delay1ms(void) //???????
- {
- int t=70;
- while(t>0)
- {
- t--;
- _nop_();
- }
- }
- void adjustTime ()
- {
- counter1=0;
- sec++;
- if(sec==60)
- {
- sec=0;
- min++ ;
- if (min==60)
- {
- min=0;
- hour++;
- }
- }
- }
- //5ms
- void wait(int time ) //?????????
- {
- while(time>0)
- {
- time--; //5ms
- delay1ms(); //????????????
- }
- }
-
- void int0() interrupt 0 using 0 //?ж??N=2 ???0????????????
- {
- TR0=!TR0 ; //
- }
- void timer0_init()
- {
- TMOD=0X01;
- TH0=0XD8; //55536/256 ???λ
- TL0=0XF0; //55536%256 ???λ 55536-D8F0 55536-D8F0
- TR0 =1; //??????
- ET0 =1;//?ж?????? ???=0 ?ж?????????
- IT0=1; //???ж?
- EX0=1;
- }
- void main()
- {
- unsigned char key_state=0;
- int i=0 ;
- //????ж???????趨??????
- //1 .10?????? t=10
- //2 .????????
- //3. ??????
- timer0_init() ;
- TMOD=0x21; //?????1??????????
- TH1=0XFD;
- TL1=0XFD;
- SCON=0X50; //????????????? 0x50??????????
- PCON=0X00;
- TR1=1;
- EA=1; //?ж???????
- //3 ??????
- while(1)
-
- {
- for(i=0;i<8;i++)
- {
- P2=i<<2; //P2=0XEF 1111 1110 //??????????
- P0= seg_code[led[i]] ;
- wait(5);
- }
-
- if(RI==1)
- {
- RI=0;
- led[0]=SBUF;
-
-
- }
- //// P2=1<<2; //P2=0XEF 1111 1110 //??????????
- //// P0= seg_code[shi] ;
- //// wait(5);
- //// P2=2<<2; //P2=0XEF 1111 1110 //???????????
- //// P0= seg_code[shi] ;
- //// wait(5);
- //// P2=3<<2; //P2=0XEF 1111 1110 //??????????
- //// P0=seg_code[ge];
- //// wait(5);
- ////
- //// P2=4<<2; //P2=0XEF 1111 1110 //??????????
- //// P0= seg_code[shi] ;
- //// P2=5<<2; //P2=0XEF 1111 1110 //??????????
- //// P0= seg_code[shi] ;
- //// P2=6<<2; //P2=0XEF 1111 1110 //???????????
- //// P0= seg_code[shi] ;
- //// wait(5);
- //// P2=7<<2; //P2=0XEF 1111 1110 //??????????
- //// P0=seg_code[ge];
- //// wait(5);
- //
- // if (flagis=1) //???? ????
- // {
- // flagis=0; //????????
- // ge++ ;
- // if(ge>9) ge=0;
-
- // }
- }
- }
- //10ms //65.536ms
- void timer0_isr() interrupt 1 using 1
- {
- // TH0=0XD8;
- // TL0=0XF0;
- static int counter1=0; // static ???????
- TH0=0XD8; //55536/256 ???λ
- TL0=0XF0; //55536%256 ???λ 55536-D8F0
-
- counter1++;
- if( counter1==100)
- {
- counter1=0;
- adjustTime ();
- // led[0]=hour/10;
- // led[1]=hour%10;
- // led[2]=17;
- // led[3]=min/10;
- // led[4]=min%10;
- // led[5]=17;
- // led[6]=sec/10;
- // led[7]=sec%10;
- }
- }
- // led[7]=ge;
- // led[6]=shi;
- //counter1++;
- // if (counter==15)
- // {
- // counter1=0;
- // flag1s=1;
- // }
复制代码
|
|