按下按键开始发送并换行,在按下按键发送下一组,目前能够实现换行和发送字符数组,但是发送下一组必须断电才能实现,序如下:
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit k1=P3^6;
void cominit(void)
{
TMOD=0x20;
PCON=0x00;
SCON=0x50;
TH1=0xfd;
TL1=0xfd;
TR1=1;
}
void delay(uint q)
{
uint x,y;
for(x=q;x>0;x--)
for(y=110;y>0;y--);
}
void main()
{
uchar i=0;
uchar code buffer[]="abcdefg\n";
uchar *p;
cominit();
p=buffer;
while(1)
{
if(k1==0)
{
delay(1);
while(k1==0);
delay(1);
while(*p!='\0')
{
SBUF=*p;
p++;
while(!TI);
TI=0;
}
}
}
}
|