我对UART RX FIFO有问题。如果我给UART外设上电,我在LSR寄存器中收到RXFE错误,UART TX工作正常。
我使用120 and和115200波特率的LPC4088
我尝试读取寄存器以清除挂起的错误,但没有成功。希望你们中的一些人能提供帮助。
void UART3_Init(void){
LPC_SYSCTL->PCONP |= (1 << 25); // Enable Power & CLock for UART3
LPC_UART3->LCR = (3 << 0) // Word Length: 8 Bit
|(0 << 2) // Stop Bit: 1 Bit
|(0 << 3) // Parity Enable: disabled
|(1 << 7); // Divisor Latch: enabled
LPC_UART3->DLL = 65; // Divisor Latch: 65 for 115200 Baud
LPC_UART3->DLM = 0; // Divisor Latch: 0 for 115200 Baud
LPC_UART3->FCR = (1 << 0) // FIFO enable: enabled
|(1 << 1) // RX FIFO reset: enabled
|(1 << 2); // TX FIFO reset: enabled
LPC_UART3->FDR = (0 << 0) // Baudrate prescaler Value: DIVADDL = 0
|(1 << 4); // Baudrate prescaler Value: MULVAL = 1
LPC_UART3->LCR &= ~(1 << 7); // disable to lock Baud - without this no UART communication
}
char UART3_receive(void){
while(!(LPC_UART3->LSR & (1 << 0))); //wait until data arrives in Rx FIFO
return LPC_UART3->RBR;
}
int main(void){
CCLK runs with 120MHz
//UART 3 Pins
LPC_IOCON->p[0][25] = (3 << 0); //UART3 TX p[0][25]
LPC_GPIO->DIR = (1 << 25);
LPC_IOCON->p[0][26] = (3 << 0); //UART3 RX p[0][26]
LPC_GPIO->DIR = (0 << 26);
UART3_Init();
char data = 0;
while(1){
data = UART3_receive();
if(data == ENTER){
//PRINT back to terminal "SUCCESS"
...
...
}
}
}发布于 2019-09-04 21:16:55
看起来发送设备有帧错误或奇偶校验问题,请检查发送器的误码率,环回测试将确保一切正常。
https://stackoverflow.com/questions/57782681
复制相似问题