简单的串口echo通信的问题
本人在测试新买单片机的串口时发现当我输入以下echo代码时,竟然不成功,不知道什么问题,请那位大虾执教一下:本人是在linux下一用C-kermit来与计算机通信,一开头是想用中断的但是不成功,又改成用轮询,但是仍旧不成功
这些代码用的是sdcc编译,在ucsim下虚拟,能通信成功的
#include"mcs51/at89S8252.h"
#include <math.h>
#include <stdio.h>
void initPort()
{
SCON = 0xd8; /* serial control byte, mode 1, RI active */
TMOD = 0x20; /* use counter1, works under mode 2*/
TH1 = 0xfd;
TL1 = 0xfd;
PCON = 0x00;
TR1 = 1; /* start the counter1*/
// ET1 = 1; /* enable timer1 interupt*/
// ES = 1;
// EA = 1; //enable the interrupt
}
void main()
{
char test;
initPort();
while(1)
{
while(RI == 0);
RI = 0;
test = SBUF;
test = test+1;
SBUF = test;
while(TI == 0);
TI = 0;
}
}
发表时间:2006年1月11日0:55:58