#include<reg51.h> #define uchar unsigned char #define uint unsigned int uchar array[]="Hello China!"; sbit P1_0=P1^0;
/*延时程序*/ void delay(uint time) { int i,j; for(i=time;i>0;i--) for(j=255;j>0;j--) {;} }
/*发送一个字节*/ void sendbyte(uchar const one_byte) { SBUF=one_byte; }
/*发送字符串*/ void sendstring(uchar const *p) { while(*p!='\0') { sendbyte(*p++); } } /*主循环*/ int main() { uchar *q; *q=array; TMOD=0x20; TH1=TL1=0xfd; SCON=0x00; PCON=0; EA=0; /*不产生中断*/ TR1=1; while(1) { sendstring(q); delay(255); P1_0=~P1_0; } }
有什么问题? |