程序中需要使用UART,初始化了UART,使用了UART的FIFO,且FIFO的深度设为1/2,发送和接收都使用中断,可是发送就是死活都不产生,请指点一下!如果不使用FIFO,即FIFO深度为1字节,那么发送、接收中断都正常。
附初始化程序
void UART0_Init(void) { UART_InitTypeDef UART_InitStructure; /* UART0 configuration -------------------------------------------------------*/ /* UART0 configured as follow: - Word Length = 8 Bits - One Stop Bit - No parity - BaudRate = 9600 baud - Hardware flow control enabled (RTS and CTS signals) - Receive and transmit enabled - Receive and transmit FIFOs are enabled - Transmit and Receive FIFOs levels have 8 bytes depth */ UART_InitStructure.UART_WordLength = UART_WordLength_8D; UART_InitStructure.UART_StopBits = UART_StopBits_1; UART_InitStructure.UART_Parity = UART_Parity_No ; UART_InitStructure.UART_BaudRate = 9600; UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_RTS_CTS; UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx; UART_InitStructure.UART_FIFO = UART_FIFO_Enable; UART_InitStructure.UART_TxFIFOLevel = UART_FIFOLevel_1_8; /* FIFO size 16 bytes, FIFO level 8 bytes */ UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */
UART_DeInit(UART0); UART_Init(UART0, &UART_InitStructure);
/*------------------------------------------------ Setup UART0 Interrupt, UART0_ITLine = 16 ------------------------------------------------*/ VIC1->VAiR[2] = (unsigned int)&UART0_irq; VIC1->INTSR &= ~(0x01 << (UART0_ITLine - 16)); VIC1->VCiR[2] = 0x20 | (UART0_ITLine - 16); VIC1->INTER |= (0x01 << (UART0_ITLine - 16));
UART_ITConfig(UART0, UART_IT_Transmit, ENABLE); // 使能发送中断 UART_ITConfig(UART0, UART_IT_Receive | UART_IT_ReceiveTimeOut, ENABLE);
/* Enable the UART0 */ UART_Cmd(UART0, ENABLE); }
|