標題: 串口數(shù)據(jù)發(fā)送 [打印本頁]

作者: achen    時間: 2017-6-1 10:49
標題: 串口數(shù)據(jù)發(fā)送
#include <reg52.h>
#define uint unsigned int
unsigned char a;
unsigned char b;
unsigned char  table[2];
void Send(unsigned char *dis)
{
        while(*dis!='\0')
        {
        SBUF=*dis;
        dis++;
        while(TI==0);
        TI=0;
        }
}
void delayms(uint xms)
{
        uint i,j;
        for(i=xms;i>0;i--)
                for(j=110;j>0;j--);
}
void main(void)
{
           TMOD=0x20;        
        SCON=0x50;
    PCON=0x00;
        TH1=0xfd;
        TL1=0xfd;
        TR1=1;
        while(1)
        {
        table[0]=P1;
        table[1]=P2;
        Send(table);
        delayms(100);
        }
}







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