导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→请教16C554A的访问方法[zergfan]

 *第48278篇: 请教16C554A的访问方法

  
楼 主:zergfan 2007年5月15日00:46
 请教16C554A的访问方法

点击浏览该文件
大家好,我做了一个小的系统,其中用到了16C554A,但是怎样也发送不出数据.下面附上一段相关的程序和

原理图,请各位费心,谢谢! 
我没有用中断,用的是16C554A的FIFO POLLED MODE.初始化之后,直接发数据. 
CPU为,MEGA64,16M晶振. 

#define TL16c554A_Base ((volatile unsigned char*) 0x8000) 
#define TL16c554B_Base ((volatile unsigned char*) 0xa000) 
#define TL16c554C_Base ((volatile unsigned char*) 0xc000) 
#define TL16c554D_Base ((volatile unsigned char*) 0xe000) 

#define RBR 0 
#define THR 0 
#define DLL 0 
#define DLM 1 
#define IER 1 
#define IIR 2 
#define FCR 2 
#define LCR 3 
#define MCR 4 
#define LSR 5 
#define MSR 6 

SREG=0x80;                     //Enable all interrupt. 
MCUCR=0xc0;                    //Enable external memory extending. 
XMCRA=0x02;                    //Disable Bus holding 
XMCRB=0x00;                    //Disble Bus release. 
XDIV=0x00;                     //Disable system clk divide. 

void Init_UART(void) 
   { 
     TL16c554_RST=0; 
     _delay_ms(1); 
     TL16c554_RST=1; 
     _delay_ms(1); 
     TL16c554_RST=0; 
     *(TL16c554A_Base+FCR)=0x0f;           // FIFO polled mode . 
     *(TL16c554A_Base+LCR)=0x80; 
     *(TL16c554A_Base+DLL)=0x06; 
     *(TL16c554A_Base+DLM)=0x00; 
     *(TL16c554A_Base+MCR)=0x00; 
     *(TL16c554A_Base+LCR)=0x03; 
     *(TL16c554A_Base+IER)=0x00; 
      
   } 

void Tx_UART(void) 
   { 
     unsigned char temp=0,i; 

     temp=*(TL16c554A_Base+LSR); 

     //Serial_TX(temp); 
     if(temp&0x60==0x60)  //读取LSR的值为0x60,表示发送寄存器和发送移位寄存器空. 
        {          //但是还是发不出数据.(通过串口发送LSR的值,可以确定为0x60) 

         *(TL16c554A_Base)=0xff; 
         _delay_ms(20); 
            
        } 
   }

  
2楼:soong 2007年5月15日14:40
 读写控制
我看你程序里好象没有读写控制啊?
是不是这个原因????

>>>>>>对该主题发表你的看法

本主题贴数2,分页: [第1页]


[上一篇主题]:求救--如何用单片机实现长时间计时????? [求助]

[下一篇主题]:[求助]哪位大虾用过酒精传感器?