標題: 單片機串口通信源碼 [打印本頁]

作者: 流星雨掉到地球    時間: 2016-11-23 15:30
標題: 單片機串口通信源碼
#include<reg52.h>
typedef unsigned char uint8;
sbit wela=P2^7;
uint8 code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71
};
void send_byte(uint8 dat)  //發(fā)送數(shù)據(jù)
{
        SBUF=dat;
        P0=dat;
        while(!TI);
        TI=0;
}
void uart_init()           //初始化
{
        SCON=0x50;
        TMOD=0X20;
        TH1=0xfd;
        TL1=0xfd;
        REN=1;
        TR1=1;
}
void main()                //主函數(shù)
{        
        uart_init();
        wela=1;
        P0=0xfb;
        wela=0;
            send_byte(table[9]);
        while(1);
}







歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1