请大家帮我看看,仿真串口能正常发送,但接收不到数据不知为何?
单片机源程序如下:
发送:
- #include <STC89C5xRC.H>
- #include<intrins.h>
- void Delay(unsigned int xms) //@11.0592MHz
- {
- unsigned char i, j;
- while(xms--)
- {
- _nop_();
- i = 2;
- j = 199;
- do
- {
- while (--j);
- } while (--i);
- }
- }
- unsigned char Ledtab[16]={0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff,0x00};
- void send(unsigned char ucdata)
- {
- SBUF = ucdata;
- while(TI==0);
- TI=0;
- }
- void main()
- {
- unsigned char i;
- TMOD=0X20;
- SCON=0X40;
- PCON=0X00;
- TH1=0XFD;
- TL1=0XFD;
- TR1=1;
- P1=0XFF;
- while(1)
- {
- for(i=0;i<16;i++)
- {
- P1=Ledtab[i];
- send(Ledtab[i]);
- Delay(200);
- }
- }
-
- }
复制代码
接收:
#include <STC89C5xRC.H>
unsigned char Receive()
{
unsigned char ucdata;
while(RI==0);
RI=0;
ucdata = SBUF;
return ucdata;
}
void main()
{
TMOD=0X20;
SCON=0X50;
PCON=0X00;
TH1=0XFD;
TL1=0XFD;
TR1=1;
REN=1;
P1=0XFF;
while(1)
{
P1=Receive();
}
}
|