博客
关于我
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/

你可能感兴趣的文章
numpy数组索引-ChatGPT4o作答
查看>>
NUMPY矢量化np.prod不能构造具有超过32个操作数的ufunc
查看>>
Numpy矩阵与通用函数
查看>>
numpy绘制热力图
查看>>
numpy转PIL 报错TypeError: Cannot handle this data type
查看>>
Numpy闯关100题,我闯了95关,你呢?
查看>>
Nutch + solr 这个配合不错哦
查看>>
NuttX 构建系统
查看>>
NutUI:京东风格的轻量级 Vue 组件库
查看>>
NutzCodeInsight 2.0.7 发布,为 nutz-sqltpl 提供友好的 ide 支持
查看>>
NutzWk 5.1.5 发布,Java 微服务分布式开发框架
查看>>
NUUO网络视频录像机 css_parser.php 任意文件读取漏洞复现
查看>>
Nuxt Time 使用指南
查看>>
NuxtJS 接口转发详解:Nitro 的用法与注意事项
查看>>
NVelocity标签使用详解
查看>>
NVelocity标签设置缓存的解决方案
查看>>
Nvidia Cudatoolkit 与 Conda Cudatoolkit
查看>>
NVIDIA GPU 的状态信息输出,由 `nvidia-smi` 命令生成
查看>>
NVIDIA-cuda-cudnn下载地址
查看>>
nvidia-htop 使用教程
查看>>