/******************************************
??????????????
???????STC89C52
???????9600
*****************************************/
#include <reg52.h>
#include<intrins.h> //????????????????????????????????
typedef unsigned int u16; //?????????????????????
typedef unsigned char u8;
unsigned char date;
#define uchar unsigned char
#define uint unsigned int
sbit key1=P3^3;
sbit beep=P1^5;
/* ???????? -----------------------------------------------*/
void delay(uint z);
void Initial_com(void);
void delay(u16 i)
{
while(i--);
}
//***********************************************************
/*
********************************************************************************
** ???????? ?? delay(uint z)
** ???????? ?? ???????
********************************************************************************
*/
void unsiged(uint z )
{
uint i,j;
for(i=z;i>0;i--)
for(j=110;j>0;j--);
}
//******************************
//*****????????????***********
//******************************
void Initial_com(void)
{
EA=1; //?????ж?
ES=1; //????????ж?
ET1=1; //????????T1???ж?
TMOD=0x20; //?????T1??????2?ж??????????
PCON=0x00; //SMOD=0
SCON=0x50; // ???1 ??????????
TH1=0xfd; //???????????9600
TL1=0xfd;
TR1=1; //???????T1???п???λ
}
//*************************
//**********??????*********
//*************************
main()
{
Initial_com();
while(1)
{
if(key1==0)
{
delay(100); //??????
if(key1==0) //??????
{
SBUF=0X01;
delay(200);
while(1)
{
beep=~beep;
delay(10); //??????100us ??????????????????????Ч??}
}
}
if(RI)
{
date=SBUF; //?????????
SBUF=date; //?????????
RI=0;
}
}
} }
|