27,382
社区成员
发帖
与我相关
我的任务
分享
unsigned char m0=0; //秒
void Delay()
{
int i;
for(i=0;i<0xff;i++)
{
}
}
void send_char_com(unsigned char ch)
{
SBUF=ch;
while(TI==0);
TI=0;
}
void send_info()
{
send_char_com(0x00);
send_char_com(0x01);
send_char_com(0x22);
send_char_com(0xff);
send_char_com(0xdd);
send_char_com(0xee);
send_char_com(0xcc);
send_char_com(0xbb);
send_char_com(0xaa);
send_char_com(0xa1);
send_char_com(0x11);
}
main()
{
EA=1;
PS=1;//串行中断为高优先级
PT0=0;// 串行中断为低优先级
TMOD=0x21;
//定时时间50ms
TH0= -46080/256;
TL0= -46080%256;
//定时器1,产生9600波特率
TH1=0xFD;
TL1=0xFD;
PCON=0;
SCON=0x50;//串行通信工作于方式1
TR1=1;
ET0=1;
TR0=1;
while(1)
{
send_info();
//延时
Delay();
Delay();
Delay();
}
}
//产生1秒的时间
void tim_0(void) interrupt 1 using 2
{
static count=0;
if(count==20)
{
m0++;
count=0;
//send_info();
}
count++;
TH0= -46080/256;
TL0= -46080%256;
}