#include<reg51.h>
#define uchar unsigned char
unsigned char table[]={0x23,0x03,0x04,0x00,0x00,0x00,0x03,0x23};
unsigned char array[]={0x23,0x04,0x00,0x23};
sbit s=P1^0;
void InitUART(void)
{
TMOD = 0x20;
SCON = 0x50;
TH1 = 0xFD;
TL1 = TH1;
PCON = 0x00;
EA = 1;
ES = 1;
TR1 = 1;
}
void delay(unsigned int i)
{
unsigned char j;
for(i; i > 0; i--)
for(j = 255; j > 0; j--);
}
void send_com(unsigned char arry[],unsigned char j) //串口数据发送函数
{
unsigned char i;
for(i=0;i<j;i++)
{
SBUF = arry[i];
while(!TI);
TI = 0;
}
}
void main()
{
InitUART();
if(s==0)
{
delay(100);
if(s==0)
{
send_com(table,4);
}
}
if(s==1)
{
delay(50);
if(s==1)
{
send_com(array,8);
}
}
}
void UARTInterrupt(void) interrupt 4
{
if(RI)
{
RI = 0;
//add your code here!
}
else
TI = 0;
}
程序烧写到板子上,没办法正常发送数据,程序的问题么? |