|
44b0的串口, AFC和FIFO功能如何使用呀?为什么我启用了这两个功能后串口就无法正常工作了呢?我的代码如下:
void init_uart()
{
/* Bit6 : infra-Red mode or not, 1 for infra-Red mode.
* bit5..3 : parity mode, 0xx for no parity.
* Bit2 : number of stop bit, 0 one stop bit, 1 two stop bit per frame.
* Bit1..0 : data bits per frame, 11 for 8 bits.
*/
rULCON0 = 0x3; /*No parity, 1 stop bit, 8 data bits*/
rULCON1 = 0x3;
/* Bit7..6 : Tx FIFO Trigger Level
* Bit5..4 : Rx FIFO Trigger Level
* Bit3 : Reserved and not used.
* Bit2 : Tx FIFO Reset
* Bit1 : Rx FIFO Reset
* Bit0 : FIFO enable or not, 0 for disable, 1 for enable.
*/
rUFCON0 = 0x1; /* FIFO enabled. */
rUFCON1 = 0x1;
/* Bit4 : Auto Flow Control(AFC) enable or not, 1 for enable, 0 for disable.
* Bit3..1 : Reserved and must be 0.
* Bit0 : nRTS, only used when AFC is disabled.
*/
rUMCON0 = 0x10; /* AFC disabled. */
rUMCON1 = 0x10;
/* Bit9 : Tx interrupt type, 0 for pulse, 1 for level
* Bit8 : Rx interrupt type, 0 for pulse, 1 for level
* Bit7 : Rx timeout enable, 0 for disable, 1 for enable
* Bit6 : Rx error status interrupt enable, 0 for disable, 1 for enable
* Bit5 : Loop-back mode, 0 for normal option, 1 for Loop-back mode
* Bit4 : Send Break Signal, 0 for normal transmit, 1 for send break signal
* Bit3..2 : Transmit Mode, 00 for disable, 01 for interrupt request or polling mode
* Bit1..0 : Receive Mode, 00 for disable, 01 for interrupt request or polling mode
*/
rUCON0 = 0x45; /* Tx is using polling mode.
* Rx is using pulse interrupt type.
* Rx timeout is disabled.
* Don't send break signal.
*/
rUCON1 = 0x45;
/* default baud rate is 57600bps. */
rUBRDIV0 = (MCLK + 8 * BAUD_DEFAULT)/(16 * BAUD_DEFAULT) - 1;
rUBRDIV1 = (MCLK + 8 * BAUD_DEFAULT)/(16 * BAUD_DEFAULT) - 1;
}
在把rUFCON和rUMCON都设为0x0时, 串口可以正常工作, 但在传输数据量大时会出现Overun Error.
[em04] |
|