用的也是TL16C554 ,初始化如下,我用了3个TL,也就是12个串口。
#define addr_5541a_base 0x8000 //1st 554的CSA的基址 #define addr_5541b_base 0x8800 //1st 554的CSB的基址 #define addr_5541c_base 0x9000 //1st 554的CSC的基址 #define addr_5541d_base 0x9800 //1st 554的CSD的基址
#define addr_5542a_base 0xa000 //2nd 554的CSA的基址 #define addr_5542b_base 0xa800 //2nd 554的CSB的基址 #define addr_5542c_base 0xb000 //2nd 554的CSC的基址 #define addr_5542d_base 0xb800 //2nd 554的CSD的基址
#define addr_5543a_base 0xc000 //3rd 554的CSA的基址 #define addr_5543b_base 0xc800 //3rd 554的CSB的基址 #define addr_5543c_base 0xd000 //3rd 554的CSC的基址 #define addr_5543d_base 0xd800 //3rd 554的CSD的基址
struct com_r{ //offset //RHR //THR uchar DLL_RHR_THR;//00 Divisor LSB latch address(Receive Holding Register,Teceive Holding Register ) uchar DLM_IER; //01 Divisor MSB Latch address,Interrupt Enable Register uchar FCR_ISR; //02 FIFO control Register,Interrupt Status Register uchar LCR; //03 Line control register uchar MCR; //04 Modem Control Register uchar LSR; //05 Line Status Register uchar MSR; //06 Modem Status Register uchar SPR; //07 Scratch pad Register };
struct com_r xdata * com[12];
void getaddress(void) { com[0] = ( struct com_r *) addr_5541a_base; //指针转换 com[1] = ( struct com_r *) addr_5541b_base; //指针转换 com[2] = ( struct com_r *) addr_5541c_base; //指针转换 com[3] = ( struct com_r *) addr_5541d_base; //指针转换 com[4] = ( struct com_r *) addr_5542a_base; //指针转换 com[5] = ( struct com_r *) addr_5542b_base; //指针转换 com[6] = ( struct com_r *) addr_5542c_base; //指针转换 com[7] = ( struct com_r *) addr_5542d_base; //指针转换 com[8] = ( struct com_r *) addr_5543a_base; //指针转换 com[9] = ( struct com_r *) addr_5543b_base; //指针转换 com[10] = ( struct com_r *) addr_5543c_base; //指针转换 com[11] = ( struct com_r *) addr_5543d_base; //指针转换 }
void com_init(void) {
uchar i = 0; uchar j = 0; getaddress();
for(i=0;i<12;i++) { com->LCR = 0x80; // enable divisor com->DLL_RHR_THR = 0x0c; // 11.0592M 9600 com->DLM_IER = 0x00; com->LCR = 0x0b; // set 8 bit data,1 bit stop,odd parity com->FCR_ISR = 0x47; // FIFO模式10001111 RXRDY/TXRDY mode 1 com->DLM_IER = 0x03; // 使能接收和发送中断03 com->MCR = 0x08; // 使能串口中断
我也是第一次写 |