|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2010-7-8 15:35:38
|
显示全部楼层
哈哈 看来问题还得我自己解决啊 被我搞定了
#include <REG52.H>
#define uchar unsigned char
#define uint unsigned int
unsigned int temp[9]={0x02,0x37,0x30,0x31,0x30,0x35,0x03,0x30,0x30};
sbit LED = P1^0;
void main ()
{
unsigned int i,mm,y;
SCON = 0x50;
TMOD |= 0x20;
TH1 = 0xFD;
TR1 = 1;
EA = 1;
while (1)
{
for(i=0;i<9;i++)
{
ACC=temp;
CY=P;
TB8=CY;
y=ACC&0x7f;
mm=0x00|TB8;
mm=mm<<7;
SBUF=y|mm;
while(!TI);
TI=0;
}
if(i==9) while(1);
}
}
刚开始偶校验这几行我就没弄太明白,
ACC=temp;
CY=P;
TB8=CY;
SBUF=ACC;
这是我在网上搜的,人家都说偶校验是这么写的,可实验证明这是不对的,经过我的改正
ACC=temp;
CY=P;
TB8=CY;
y=ACC&0x7f;
mm=0x00|TB8;
mm=mm<<7;
SBUF=y|mm;
现在已经能给PLC置位啦 哈哈这一天总算是有点成果啦 |
|