标题: 单片机串口方式0实现并行数据、串行数据转换 [打印本页]

作者: 18789007389    时间: 2018-7-16 17:04
标题: 单片机串口方式0实现并行数据、串行数据转换
#include <reg52.h>
#include <intrins.h>
#include <stdio.h>
#define uint unsigned int
#define uchar unsigned char
sbit SPL = P2^5;

void Delay(uint x)
{
         uchar i;
        while(x--)
        {
                 for(i=0;i<120;i++);
        }
}

void main()
{
         SCON = 0x10;
        while(1)
        {
                 SPL = 0;
                SPL = 1;
                while(RI == 0);
                RI = 0;
                P0 = SBUF;
                Delay(20);
        }
}






欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1