- 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);
}
}
}
您可能关注的文档
- 单片机控制技术实训计划_1603电气技术.doc
- 单片机理论题库(有答案).doc
- 单片机面试题2.doc
- 单片机模拟试卷001.doc
- 单片机判断题.doc
- 单片机判断题复习题库.doc
- 单片机跑马灯实验.doc
- 单片机汽车转向灯设计.doc
- 单片机清零程序.doc
- 单片机驱动ADC0832模数转换程序.doc
- 2025年版汽车趋势报告 The 2025 EPA Automotive Trends Report.docx
- 2026年边缘计算开源平台EdgeX Foundry入门与二次开发.docx
- 2026年超声内镜放大内镜早癌诊断AI辅助识别系统临床评价.docx
- 2026年报废汽车回收与再制造逆向物流体系.docx
- 2026年产品碳足迹核算方法学:从摇篮到大门与从摇篮到坟墓.docx
- 2026年城乡要素平等交换双向流动政策创新试点申报材料.docx
- 2026年超导半导体接口电路架构与电平转换驱动器设计.docx
- 2026年财政贴息不再以再贷款支持为前提后的风险防范与合规要点.docx
- 2026年不动产信托登记试点政策对遗嘱信托支持.docx
- 2026年城乡有机废弃物协同处理技术方案.docx
原创力文档

文档评论(0)