#include"reg52.h"
#include"FD650.h"
#define uchar unsigned char
#define uint unsigned int
/*code uchar d[10]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90}; */
uint c=1234;
//uint sshi,sge,sbai,sqian;
static char court=0;
/*sbit P20=P2^0;
sbit P21=P2^1;
sbit P22=P2^2;
sbit P23=P2^3;
sbit P24=P2^4;
sbit P25=P2^5;
sbit P26=P2^6;
sbit P27=P2^7; */
sbit K1=P3^0;
sbit K2=P3^1;
sbit K3=P3^2;
sbit K4=P3^3;
uchar sty=0;
uchar time[4];
uchar table[10]={0x3f,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7f,0x6f};
/*******************************************************************/
/*add SW FP location variable*/
/*************************************************************************************/
/****************************************************************
*
* Function Name:FD650_Start
*
* Description:
*
* Parameter:
*
* return:
****************************************************************/
void FD650_Start( void )
{
FD650_SDA_SET;
// FD650_SDA_D_OUT;
FD650_SCL_SET;
// FD650_SCL_D_OUT;
augenstern什么意思DELAY;
FD650_SDA_CLR;
DELAY;
FD650_SCL_CLR;
}
/****************************************************************
*
* Function Name:FD650_Stop
*
* Description:
*
* Parameter:
*
* return:
****************************************************************/
void FD650_Stop( void )
{
FD650_SDA_CLR;
// FD650_SDA_D_OUT;
DELAY;
FD650_SCL_SET;
DELAY;
FD650_SDA_SET;
DELAY;冰冻星球下载
// FD650_SDA_D_IN;
}
/****************************************************************
*
* Function Name:FD650_WrByte
*
* Description: Write One Byte data
*
* Parameter: data
*
hoot
氓翻译* return:
****************************************************************/
void FD650_WrByte( u_int8 dat )
{
u_int8 i;
// FD650_SDA_D_OUT;
for( i = 0; i != 8; i++ )
{
if( dat & 0x80 )
{
FD650_SDA_SET;
}
el
{
FD650_SDA_CLR;
}
DELAY;
FD650_SCL_SET;
dat <<= 1;
DELAY; // 可选延时
FD650_SCL_CLR;
}
/
/FD650_SDA_D_IN;
FD650_SDA_SET;
DELAY;
FD650_SCL_SET;
DELAY;
FD650_SCL_CLR;
}
/****************************************************************
*
* Function Name:FD650_WrByte
*
* Description: Read One Byte data
*
* Parameter:
*
* return:data
****************************************************************/
u_int8 FD650_RdByte( void )
{
u_int8 dat,i;
FD650_SDA_SET;
//FD650_SDA_D_IN;
dat = 0;
ask
for( i = 0; i != 8; i++ )
{
DELAY; // 可选延时
FD650_SCL_SET;
DELAY; // 可选延时
dat <<= 1;
if( FD650_SDA_IN ) dat++;
FD650_SCL_CLR;
}
FD650_SDA_SET;
DELAY;
FD650_SCL_SET;
DELAY;
FD650_SCL_CLR;
return dat;
}
/****************************************FD650操作函数*********************************************/
/****************************************************************
*
* Function Name:FD650_Write
*
* Description:通过发送命令
参数
*
* Parameter: cmd见FD650.H
*
* return:无
****************************************************************/
void FD650_Write( u_int16 cmd ) //写命令
{
FD650_Start();
FD650_WrByte(((u_int8)(cmd>>7)&0x3E)|0x40);
FD650_WrByte((u_int8)cmd);
FD650_Stop();
return;
}
/****************************************************************
*
* Function Name:FD650_Read
*
* Description:读取按键按下状态的键值,如读到无效按键值返回0the moment of truth
*
* Parameter: 无
*
* return:按键按下状态的键值
****************************************************************/
u_int8 FD650_Read( void ) //读取按键
{
u_int8 keycode = 0;
FD650_Start();
FD650_WrByte((u_int8)(FD650_GET_KEY>>7)&0x3E|0x01|0x40);
keycode=FD650_RdByte();
FD650_Stop();
if( (keycode&0x00000040) ==0)
keycode = 0;
return keycode;
}
void delay()
{
uchar i;
for(i=0;i<15;i++);
}
void delayus(uchar i)
考研报名信息填写
{
while(i--);
}
void delays(uchar j) //误差 0us
{
unsigned char a,b,c;
yinyinfor(c=j;c>0;c--)
for(b=142;b>0;b--)
for(a=2;a>0;a--);
}
void FD650_Show_StandbyTime(uchar *c)
{
uchar i = 0;
uchar dat[4];
/* iLenth = strlen(TimeString);
if(iLenth>4)
{
iLenth = 4;
}
*/
for(i=0; i<4; i++)
{
dat[i] =table[c[i]];
}
FD650_Write(FD650_DIG0 | (uchar)dat[0]);//点亮第一个数码管
FD650_Write(FD650_DIG1 | (uchar)dat[1]); //点亮第二个数码管
FD650_Write(FD650_DIG2 | (uchar)dat[2]); //点亮第三个数码管
FD650_Write(FD650_DIG3 | (uchar)dat[3]); //点亮第四个数码管
}
void int1() interrupt 1 using 2
{
TH0=0x4c;
TL0=0x00;
court++;
}
aiv
void int2() interrupt 3
{
EA=0;
if((!P30)|(!P31)|(!P32)|(!P33))
{ if(P30==0)
delayus(10);
if(P30==0)
{
sty++;
if(sty==5)
sty=1;
}
if(P31==0)
delayus(5);
if(P31==0)
{
c++;
if(c==10000)
c=0;
}
}
EA=1;kame
}
void main()
{
TMOD=0x21;
TH0=0x4c;
TL0=0x00;
TH1=0xe0;
TL1=0xe0;
EA=1;
ET0=1;
ET1=1;
TR0=1;
TR1=1;
FD650_Write(FD650_SYSON );
FD650_Write(FD650_7SEG_ON);
for(;;)
{
time[0]=c/1000;
time[1]=c/100%10;
time[2]=c/10%10;
time[3]=c%10;
FD650_Show_StandbyTime(time);
if(court==20)
{
court=0;
c--;
if(c==10000)
{
c=0;
}
}
}
}