标题:关于异步FIFO芯片的串口读取通讯程序问题,高手请进(程序很短)
只看楼主
飘逸的心
Rank: 2
等 级:论坛游民
帖 子:29
专家分:59
注 册:2010-3-17
结帖率:100%
 问题点数:0 回复次数:0 
关于异步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这种十六进制数据,即使超过了程序本身设定的五百次也会继续发送!
希望能够碰到单片机高手帮助我解决这个问题,万分感谢!
搜索更多相关主题的帖子: system test 
2011-04-19 10:48



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-337199-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.096872 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved