|
串口0为片内自带的,初始化的时候,U0FCR这个寄存器总是写不进去值,请教高手~~~
附代码:[code]
INT8U UART0_Init( INT32U baudrate)
{
INT32U Fdiv;
PINSEL0 &= 0xFFFFFF0F;
PINSEL0 |= 0x00000050; /* P0.3 to RxD0 and P0.2 to TxD0 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
switch(baudrate)
{ case 115200:
U0DLM = 0;
U0DLL = 25;
U0FDR = 0x41;
break;
case 9600:
U0DLM = 0x01;
U0DLL = 0x77;
break;
default:
Fdiv = ( Fpclk / 16 ) / baudrate ;
U0DLM = Fdiv / 256;
U0DLL = Fdiv % 256;
break;
}
U0LCR = 0x03;
U0FCR = 0xC7; //触发深度设定为14个字节
U0IER = IER_RBR | IER_THRE | IER_RLS;
if ( install_irq( UART0_INT, (void *)UART0_Handler, UART0_PRIORITY ) == FALSE )
{
return (FALSE);
}
return (TRUE);
}
|
|