博客
关于我
51单片机串口的使用
阅读量:335 次
发布时间:2019-03-04

本文共 1674 字,大约阅读时间需要 5 分钟。

????????UART??????????????????????????????????????????????????????????????????????????????????????????????????1. ?????????????????????2. ????????????SBUF registers??????3. ???????????????????????????4. ?????????????????????????5. ?????????????1????2?????????6. ????????????????????????????????????????????????????????????????????????????????????????????```cvoid delay(long d) {    while(d--) ;}void uar1tByte(char byte) {    SBUF = byte;    while(!TI);    TI = 0;}void uart1String(char *s) {    while(*s) {        uar1tByte(*s++);    }}void uart1Figure(long figure) {    if(figure >= 100000000) uart1tByte('0' + figure/100000000%10);    if(figure >= 10000000) uart1tByte('0' + figure/10000000%10);    if(figure >= 1000000) uart1tByte('0' + figure/1000000%10);    if(figure >= 100000) uart1tByte('0' + figure/100000%10);    if(figure >= 10000) uart1tByte('0' + figure/10000%10);    if(figure >= 1000) uart1tByte('0' + figure/1000%10);    if(figure >= 100) uart1tByte('0' + figure/100%10);    if(figure >= 10) uart1tByte('0' + figure/10%10);    if(figure >= 0) uart1tByte('0' + figure/1%10);}void uart1TiINIT() {    unsigned int INITValue = 256 - (11059200/12/32/9600);    EA = 1; ES = 1; SCON = 0x50; TMOD = 0x0F;    TMOD |= 0x20; TH1 = TL1 = INITValue; ET1 = 0; TR1 = 1;}void uart1T2INIT() {    unsigned int INITValue = 65536 - (11059200/32/9600);    EA = 1; ES = 1; SCON = 0x50; T2CON = 0x34;    TH2 = RCAP2H = INITValue / 256; TL2 = RCAP2L = INITValue % 256; TR2 = 1;}int main() {    uart1T2INIT();    while(1) {        i++;        uart1String("i = ");        uart1Figure(i);        uart1String("\r\n");        delay(10000);    }}

????????UART?????????????????????????????

转载地址:http://fbrq.baihongyu.com/

你可能感兴趣的文章
nginx 常用配置记录
查看>>
Nginx 我们必须知道的那些事
查看>>
Nginx 的 proxy_pass 使用简介
查看>>
Nginx 的配置文件中的 keepalive 介绍
查看>>
Nginx 负载均衡与权重配置解析
查看>>
Nginx 负载均衡详解
查看>>
nginx 配置 单页面应用的解决方案
查看>>
nginx 配置https(一)—— 自签名证书
查看>>
nginx 配置~~~本身就是一个静态资源的服务器
查看>>
Nginx 配置解析:从基础到高级应用指南
查看>>
nginx+Tomcat性能监控
查看>>
Nginx下配置codeigniter框架方法
查看>>
nginx报错:the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:128
查看>>
nginx添加模块与https支持
查看>>
Nginx用户认证
查看>>
Nginx的Rewrite正则表达式,匹配非某单词
查看>>
Nginx的使用总结(一)
查看>>
Nginx的使用总结(二)
查看>>
Nginx的可视化神器nginx-gui的下载配置和使用
查看>>
Nginx的是什么?干什么用的?
查看>>