求大佬解答:怎样让数码管第二位小数点常亮
#include <reg51.h>
sbit wei1=P3^4;
sbit wei2=P3^5;
sbit wei3=P3^6;
sbit wei4=P3^7;
sbit led=P1^0;
unsigned char segdat[16]=
{0xc0,
0xf9,
0xa4,
0xb0,
0x99,
0x92,
0x82,
0xf8,
0x80,
0x90, };
unsigned int cnt=0,kevval;
void delay(unsigned int x);
void display_seg4(unsigned int dat,unsigned char tim);
void INIT_int0(void);
unsigned int js=0;
unsigned char flag=0;
void main(void)
{
INIT_int0();
while(1)
{
if(flag==1)
{
js++;
if(js>=10000)
{
js=0;
}
}
if(flag==0)
{
js=0;
}
display_seg4(js,2);
}
}
void zduan(void) interrupt 0
{
flag++;
if(flag==3)
flag=0;
}
void delay(unsigned int x)
{
unsigned int i,j;
for(i=0;i<x;i++)
{
for(j=0;j<100;j++)
{
;
}
}
}
void INIT_int0(void)
{
IT0=1;
IE0=0;
EX0=1;
EA=1;
}
void display_seg4(unsigned int dat,unsigned char tim)
{
unsigned char tmp;
tmp=dat/1000%10;
P2=segdat[tmp];
wei1=1;
delay(20);P2=0xff;wei1=0;
tmp=dat/100%10;
P2=segdat[tmp];
wei2=1;
delay(20); P2=0xff;wei2=0;
tmp=dat/10%10;
P2=segdat[tmp];
wei3=1;
delay(20); P2=0xff;wei3=0;
tmp=dat%10;
P2=segdat[tmp];
wei4=1;
delay(20); P2=0xff;wei4=0;
}
|