单片机向主机发送字符串.docVIP

  • 14
  • 0
  • 约小于1千字
  • 约 2页
  • 2020-09-26 发布于浙江
  • 举报
单片机向主机发送字符串 #includereg51.h #define uchar unsigned char #define uint unsigned int void Delay(uint x) { uchar i; while(x--) for(i=0;i120;i++); } void putc_to_SerialPort(uchar c) { SBUF=c; while(TI==0); TI=0; } void puts_to_SerialPort(uchar *s) { while(*s!=\0) { putc_to_SerialPort(*s); s++; Delay(5); } } void main() { uchar c=0; SCON=0x40; TMOD=0x20; PCON=0x00; TH1=0xFD; TL1=0xFD; TI=0; TR1=1; Delay(200); puts_to_SerialPort(Receiving From 8051...\r\n); puts_to_SerialPort(-----------------\r\n); Delay(50); while(1) { putc_to_SerialPort(c+A); Delay(100); putc_to_SerialPort( ); Delay(100); if(c==25) { puts_to_SerialPort(\r\n-----------\r\n); Delay(100); } c=(c+1)%26; if(c%10==0) { puts_to_SerialPort(\r\n); Delay(100); } } }

文档评论(0)

1亿VIP精品文档

相关文档