如圖 我想把這三個數取過來 231 是定義三個數組呢 還是直接使用變量賦值 這下面是我寫的 但是取不出來
- #include<stc12.h>//頭文件
- sbit DU=P2^6;
- sbit WE=P2^7;
- unsigned int date[6],value,one,two,three;
- unsigned char num=0;
- unsigned int code sz[4]={0x3f,0x06,0x5b ,0x4f};
- void delay(unsigned char xms) //xms等于幾就延遲幾毫秒
- {
- unsigned int i,j;
- for(i=xms;i>0;i--)
- for(j=112;j>0;j--);
- }
- void UartConfiguration()
- {
-
- TMOD=0x20; //定時器工作方式,選擇了定時器1,工作方式2 八位初值自動重裝的8位定時器。
- TH1=0xfd; //定時器1初值 ,設置波特率為9600 晶振11.0529MHZ?
- TL1=0xfd;
- AUXR |= 0x40; //定時器1時鐘為Fosc,即1T
- AUXR &= 0xFE; //串口1選擇定時器1為波特率發(fā)生器
- TR1=1; //開啟定時器1
- SCON=0X50;
- PCON=0X00;
-
- ES=1; //允許串口中斷
- EA=1; //允許中斷(總閘)
- }
- void main()
- {
- UartConfiguration();
- while(1)
- {
- // one=date[0]%10;
- // two=date[2]%10;
- // three=date[4]%10;
-
- one=value%10;
- two=(value%100)/10;
- three=value/100;
- P0=sz[one];
- DU=1;
- DU=0;
- P0=0x7f;
- WE=1;
- WE=0;
- delay(2);
- P0=sz[two];
- DU=1;
- DU=0;
- P0=0xbf;
- WE=1;
- WE=0;
- delay(2);
- P0=sz[three];
- DU=1;
- DU=0;
- P0=0xdf;
- WE=1;
- WE=0;
- delay(2);
-
- }
- }
- void Uart() interrupt 4
- {
- if(RI==1)
- {
- RI=0;
- // date[num]=SBUF;
- // num++;
- // if(num==7)
- // {
- // num=0;
- // }
- value=SBUF;
-
- }
- }
復制代碼 |