|
发表于 2005-1-14 08:45:51
|
显示全部楼层
随便看看吧,DATASHEET应该讲得很清楚了
/****************************************************************************
【功能说明】异步串行口初始化
****************************************************************************/
void Uart_Init(int mclk,int baud)
{
int i;
if(mclk==0)
mclk=MCLK;
rUFCON0=0x0; //FIFO disable
rUFCON1=0x0;
rUMCON0=0x0;
rUMCON1=0x0;
//UART0
rULCON0=0x3; //Normal,No parity,1 stop,8 bit
// rULCON0=0x7; //Normal,No parity,2 stop,8 bit
rUCON0=0x245; //rx=edge,tx=level,disable timeout int.,enable rx error int.,normal,interrupt or polling
rUBRDIV0=( (int)(mclk/16./baud + 0.5) -1 );
//UART1
// rULCON1=0x7; //Normal,No parity,2 stop,8 bit
rULCON1=0x3;
rUCON1=0x245;
rUBRDIV1=( (int)(mclk/16./baud + 0.5) -1 );
for(i=0;i<100;i++);
}
//*************************************************************************** |
|