关于异步FIFO芯片的串口读取通讯程序问题,高手请进(程序很短)
#include<reg52.h>sbit FIFO_FF=P2^0;
sbit FIFO_bus=P1;
sbit FIFO_R=P2^2;
unsigned int test=1;
unsigned char system[]="system online";
unsigned char dataok[]="data ok!";
unsigned char AD_data[];
void UART_T (unsigned char UART_data)
{
SBUF = UART_data;
while(TI == 0);
TI = 0;
}
void UART_init (void)
{
TMOD = 0x20;
SCON = 0x50;
TH1 = 0xF3;
TL1 = 0xF3;
PCON = 0x80;
TR1 = 1;
}
void UART_TC (unsigned char *str)
{
while(*str != '\0')
{
UART_T(*str);
*str++;
}
*str = 0;
}
void delay (unsigned int a)
{
unsigned int i;
while( a-- != 0)
{
for(i = 0; i < 600; i++);
}
}
void main (void)
{
UART_init();
while(1)
{
if(RI==1)
{
unsigned int i;
for(i=0;i!=13;i++)
{
UART_T(0x00+system[i]);
RI=0;
}
if(test==1)
{
if(FIFO_FF==1)
{
unsigned int a;
unsigned int c;
c=0;
a=0;
there1:
for(a=0;a!=9;a++)
{
UART_T(dataok[a]);
RI=0;
}
if(c!=500)
{
c++;
FIFO_R=0;
AD_data[c]=FIFO_bus;
FIFO_R=1;
UART_T(0x30+AD_data[c]);
RI=0;
goto there1;
if(c>500)
{
test=0;
}
}
}
}
RI=0;
}
}
}
--------------------------------分割线--------------------------------
这个程序的目的是从异步FIFO芯片中读取500个数据并且从串口发送
但是运行后程序会一直卡在读取数据那一部分,不断的传出0x01和0x31这种十六进制数据,即使超过了程序本身设定的五百次也会继续发送!
希望能够碰到单片机高手帮助我解决这个问题,万分感谢!