请教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);
}
}
发表时间:2007年5月15日0:46:59