標題:
RS485串口通信C程序
[打印本頁]
作者:
axy1
時間:
2017-4-25 22:43
標題:
RS485串口通信C程序
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit P12=P1^2;
char code str[] = "you are the best! \n\r";
void main()
{
uint j;
TMOD=0x20;
TL1=0xfd;
TH1=0xfd;
SCON=0x50;
PCON &= 0xef;
TR1=1;
IE=0x00;
P12=1;
while(1)
{
uchar i=0;
while(str[i]!='\0')
{
SBUF=str[i];
while(!TI);
TI=0;
i++;
}
for(j=0;j<50000;j++);
}
}
作者:
dzbj
時間:
2017-4-25 22:49
樓主這個不能叫通訊程序 應該叫發(fā)送程序 P12是485芯片的使能控制吧 一直拉高只能發(fā)送 沒有拉低沒法接收
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1