LESSON4_3.C(58): warning C206: 'dispaly': missing function-prototype
LESSON4_3.C(58): error C267: 'dispaly': requires ANSI-style prototype
/***3.利用动态扫描和定时器1在数码管上显示出从765432开始以1/10秒的速度往下递减直至765398
并保持显示此数,与此同时利用定时器T0以500MS速度进行流水灯从上至下移动,
当数码管上数减到停止时,实验板上流水灯也停止然后全部开始闪烁,
3秒后(用T0定时)流水灯全部关闭、数码管上显示出“HELLO”。到此保持住。**/
#include<reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
/********************************************************************
1ms延时程序
*********************************************************************/
void delay (unsigned int a) // 1ms延时程序
{
unsigned int i;
while(a--)
{
for(i = 0; i < 100; i++);//STC单片机在外部晶振为12MHz时i值上限为600
} //AT89C51单片机在外部晶振为11.0592Hz为86
}
/*******************************************************************
共阳数码管
********************************************************************/
uchar code table[]={0xc0, 0xf9, 0xa4, 0xb0,0x99, //01234
0x92, 0x82,0xf8,0x80,0x90, //56789
0xa0, 0x83, 0xa7, 0xa1, 0x84, //字母a-e 10-15
0x8e, 0xbf, 0x7f, //F,符号(-),小数点 16-18
0x89, 0xc7, 0xc0}; //19-21
/********************************************************************/
uchar t0, t1, flag1, flag2;
uchar shu, ge, shi,bai;
uchar temp;
void display(char a, char b, char c, char d, char e, char f);
void main()
{
shu=432;
P0=0xfe;
temp=P0;
TMOD=0x11; //定时器1,0开方式1
TR1=1;
TR0=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
EA=1;
ET0=1;
ET1=1;
while(1)
{
if(shu==398)
flag1=1;
if(!flag2)
dispaly(7,6,5,bai,shi,ge);
else
display(16,19,15, 20, 20,21);
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
t0++;
if(!flag1)
{
if(t0==10)
{
t0=0;
temp=_crol_(temp,1);
P0=temp;
}
}
else
{
P0=0xff;
if(t0%4==0)
{
P0=~P0;
}
if(t0==60)
{
P0=0xff;
flag2=1;
TR0=0; //关闭定时器0
TR1=0;
}
}
}
void timer1() interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
t1++;
shu--;
bai=shu % 100;
shi=(shu/100)%10;
ge=shu%10;
}
//数码管显示
void display(char a, char b, char c, char d, char e, char f)
{
P2=0xfe;
P0=table[a];
delay(3);
P0=0xff;
P2=0xfd;
P0=table[b];
delay(3);
P0=0xff;
P2=0xfb;
P0=table[c];
delay(3);
P0=0xff;
P2=0xf7;
P0=table[d];
delay(3);
P0=0xff;
P2=0xef;
P0=table[e];
delay(3);
P0=0xff;
P2=0xdf;
P0=table[f];
delay(3);
P0=0xff;
} |