最近在调试这款芯片,已经能实现对芯片寄存器的正确读写,按照DATASHEET里说的进行寄存器设置之后,始终不能发送和接收数据,不知道是那方面没有设置好。我用的TMS320F2812与TL16C752进行通讯的。下面是我的初始化程序:
unsigned int * UARTA_LCR = (unsigned int *)0x004003; //寄存器设置
unsigned int * UARTA_DLL = (unsigned int *)0x004000;
unsigned int * UARTA_DLH_IER = (unsigned int *)0x004001;
unsigned int * UARTA_EFR = (unsigned int *)0x004002;
unsigned int * UARTA_MCR = (unsigned int *)0x004004;
unsigned int * UARTA_SPR = (unsigned int *)0x004007;
unsigned int * UARTA_MSR = (unsigned int *)0x004006;
unsigned int * UARTA_LSR = (unsigned int *)0x004005;
void InitUARTA()
{
unsigned int i;
GpioDataRegs.GPADAT.bit.GPIOA11 = 1;
for(i=0;i<10000;i++)
{;}
GpioDataRegs.GPADAT.bit.GPIOA11 = 0;//芯片复位
for(i=0;i<10000;i++)
{;}
* UARTA_LCR = 0x80;
for(i=0;i<10;i++)
{;}
for(i=0;i<10;i++)
{;}
* UARTA_DLL = 0x0C; // 配置A路波特率为9600
for(i=0;i<10;i++)
{;}
* UARTA_DLH_IER = 0x00;
for(i=0;i<10;i++)
{;}
* UARTA_LCR = 0xbf;
for(i=0;i<10;i++)
{;}
* UARTA_EFR = 0x10;
for(i=0;i<10;i++)
{;}
* UARTA_LCR = 0x00;
for(i=0;i<10;i++)
{;}
* UARTA_MCR = 0x08;
for(i=0;i<10;i++)
{;}
* UARTA_LCR = 0x03; //选择寄存器组,设置数据格式
for(i=0;i<10;i++)
{;}
* UARTA_EFR = 0x0f;
for(i=0;i<10;i++)
{;}
* UARTA_DLH_IER = 0x01; //使能接收中断
for(i=0;i<10;i++)
{;}
} |