|
void Delay(unsigned long x)
{
while(x--);
}
show(uchar time[])
{
uchar time0,gw,sw, time1,time2;//
unsigned long t=500;
//uint t=2;
time0=time[0]; time[0]為得到的秒BCD碼
//*既然是BCD碼的格式, 數(shù)據(jù)只能按下面處理*******//
gw=time0&0x0f;
sw=(time0>>4)&0x07;
//sw=time0/16; 求十位;
//gw=time0%16; 求個位;
DDRA|=BIT(3);//把PA3設(shè)為輸出
DDRA|=BIT(4);//把PA4設(shè)為輸出
DDRB=0XFF;//把PB口設(shè)為輸出型,全為高
PORTA|=BIT(3);
PORTB=Number[sw];
PORTA&=~BIT(3);
PORTB=0XFF;
PORTB&=~BIT(4);//位選四顯示分十位
PORTA|=BIT(4);
PORTA&=~BIT(4);
Delay(t);
PORTA|=BIT(3);
PORTB=Number[gw];
PORTA&=~BIT(3);
PORTB=0XFF;
PORTB&=~BIT(5);//位選四顯示分個位
PORTA|=BIT(4);
PORTA&=~BIT(4);
Delay(t);
} |
|