/***********STC8H8K64U两位数码管显示***************/
/*****************QQ:74145445**********************/
/*****************快手:共同学习stm8****************/
/*****************20221221*************************/
/**************************************************/
#include<STC8H.H>
sbit led_1_a =P2^4;
sbit led_1_b =P2^3;
sbit led_1_c =P4^6;
sbit led_1_d =P7^7;
sbit led_1_e =P7^6;
sbit led_1_f =P2^6;
sbit led_1_g =P2^7;
sbit led_1_dp =P0^0;
sbit led_1_3 =P4^5;
sbit led_1_5 =P2^5;
sbit led_2_a =P4^1;
sbit led_2_b =P7^3;
sbit led_2_c =P0^5;
sbit led_2_d =P5^2;
sbit led_2_e =P0^4;
sbit led_2_f =P4^3;
sbit led_2_g =P4^4;
sbit led_2_dp =P0^6;
sbit led_2_3 =P5^3;
sbit led_2_5 =P4^2;
/**************************************************/
unsigned char code led[]={
0x3F,0x06,0x5B,0x4F,0x66,0x6D,
0x7D,0x07,0x7F,0x6F}; // 0~9
/**************************************************/
void xianshi();
void yanshi();
unsigned char xianshi_a1;
unsigned char xianshi_shi,xianshi_ge;
/**************************************************/
void main()
{
unsigned char a1;
unsigned char b1,b2;
/**************************************************/
P0M0 |=(1<<0)+(1<<5)+(1<<4)+(1<<6);
P0M1 &=~((1<<0)+(1<<5)+(1<<4)+(1<<6));
P2M0 |=(1<<5)+(1<<4)+(1<<3)+(1<<6)+(1<<7);
P2M1 &=~((1<<5)+(1<<4)+(1<<3)+(1<<6)+(1<<7));
P4M0 |=(1<<6)+(1<<5)+(1<<1)+(1<<3)+(1<<4)+(1<<2);
P4M1 &=~((1<<6)+(1<<5)+(1<<1)+(1<<3)+(1<<4)+(1<<2));
P5M0 |=(1<<2)+(1<<3);
P5M1 &=~((1<<2)+(1<<3));
P7M0 |=(1<<7)+(1<<6)+(1<<3);
P7M1 &=~((1<<7)+(1<<6)+(1<<3));
/**************************************************/
a1=0;
while(1)
{
b1=a1/10;
b2=a1%10;
xianshi_shi=led[b1];
xianshi_ge=led[b2];
xianshi();
yanshi();
a1++; if(a1>99){a1=0;}
}
}
/**************************************************/
void yanshi()
{
unsigned int y;
unsigned char z;
for(y=1000;y>0;y--)
for(z=200;z>0;z--);
}
/**************************************************/
void xianshi()
{
led_1_3=1;
led_1_5=1;
if(xianshi_shi&(1<<0)){led_1_a=0;}else{led_1_a=1;}
if(xianshi_shi&(1<<1)){led_1_b=0;}else{led_1_b=1;}
if(xianshi_shi&(1<<2)){led_1_c=0;}else{led_1_c=1;}
if(xianshi_shi&(1<<3)){led_1_d=0;}else{led_1_d=1;}
if(xianshi_shi&(1<<4)){led_1_e=0;}else{led_1_e=1;}
if(xianshi_shi&(1<<5)){led_1_f=0;}else{led_1_f=1;}
if(xianshi_shi&(1<<6)){led_1_g=0;}else{led_1_g=1;}
if(xianshi_shi&(1<<7)){led_1_dp=0;}else{led_1_dp=1;}
led_2_3=1;
led_2_5=1;
if(xianshi_ge&(1<<0)){led_2_a=0;}else{led_2_a=1;}
if(xianshi_ge&(1<<1)){led_2_b=0;}else{led_2_b=1;}
if(xianshi_ge&(1<<2)){led_2_c=0;}else{led_2_c=1;}
if(xianshi_ge&(1<<3)){led_2_d=0;}else{led_2_d=1;}
if(xianshi_ge&(1<<4)){led_2_e=0;}else{led_2_e=1;}
if(xianshi_ge&(1<<5)){led_2_f=0;}else{led_2_f=1;}
if(xianshi_ge&(1<<6)){led_2_g=0;}else{led_2_g=1;}
if(xianshi_ge&(1<<7)){led_2_dp=0;}else{led_2_dp=1;}
}
/**************************************************/
|