1.�ۼ� ea Դ��
2.用定时器计数器t1以方式2计数,累加要求每计满180次进行累加器循环右移操作
�ۼ� ea Դ��
#include<reg.h>unsigned char ledtab[]={ 0xc0,源码源码有什用母婴店拍照溯源码0xf9,0xa4,0xb0,0x,0x,0x,0xf8,0x,0x,0x,0x,0xc6,0xa1,0x,0x8e,0xff};
unsigned char sec,min,hour,scanled;
unsigned char key,mode,time;
unsigned char disdat[6];
bit upbit;
sbit keyu=P3^0;
sbit keyd=P3^1;
void delay(unsigned int x)
{
unsigned int i,j;
for(i=0;i<x;i++)
for(j=0;j<;j++);
}
void dischg()
{
disdat[0]=sec/;
disdat[1]=sec%;
disdat[2]=min/;
disdat[3]=min%;
disdat[4]=hour/;
disdat[5]=hour%;
}
void t0isr() interrupt 1 //秒计时
{
TR0=0;
TH0=0x3c;
TL0=0xb0;
TR0=1;
time++;
if(time==)
{
time=0;
if(upbit==1)
{
sec++;
if(sec>)
{
sec=0;
min++;
if(min>)
{
hour++;
if((mode==0)&&(hour>))hour=0;
if((mode==1)&&(hour>))hour=0;
}
}
}
else
{
if((sec==0)&&(min==0)&&(hour==0))goto t0end;
if(sec!=0)sec--;
else
{
sec=;
if(min!=0)min--;
else
{
min=;
hour--;
}
}
}
}
t0end:
dischg();
}
void t1isr() interrupt 3 //显示
{
TR1=0;
TH1=0xec;
TL1=0x;
TR1=1;
switch(scanled)
{
case 0:
P2=0x;
P0=ledtab[disdat[4]];
break;
case 1:
P2=0x;
P0=ledtab[disdat[5]];
break;
case 2:
P2=0x;
P0=ledtab[disdat[2]];
break;
case 3:
P2=0x;
P0=ledtab[disdat[3]];
break;
case 4:
P2=0x;
P0=ledtab[disdat[0]];
break;
case 5:
P2=0x;
P0=ledtab[disdat[1]];
break;
default:break;
}
scanled++;
scanled%=6;
}
main()
{
TMOD=0x;
TH0=0x3c;
TL0=0xb0;
TH1=0xec;
TL1=0x;
EA=1;
TR0=1;
TR1=1;
ET0=1;
ET1=1;
sec=0;
min=0;
hour=0;
scanled=0;
time=0;
mode=0;
upbit=1;
while(1)
{
if(keyu==0)
{
delay();
if(keyu==0)
{
while(keyu==0);
upbit=1;
}
}
if(keyd==0)
{
delay();
if(keyd==0)
{
while(keyd==0);
upbit=0;
}
}
}
}
用定时器计数器t1以方式2计数,要求每计满次进行累加器循环右移操作
ORG H
LJMP MAIN
ORG BH
LJMP T1ISR
ORG H
MAIN:
MOV TMOD,累加点股指标源码#H
MOV TH1,#(-)
MOV TL1,#(-)
SETB TR1
SETB ET1
SETB EA
SJMP $
T1ISR:
RR A
RETI
END