Content originally posted in LPCWare by jb111 on Thu Jan 29 18:07:04 MST 2015
Hi,
Im using the LPC1837 with LPCExpresso. So far Ive been able to send characters via UART0, but I am unable to receive any characters. Ive been using the uart functions from the header lpc18xx_uart.h in the CMSIS driver library.
I think I have narrowed it down to a problem in software, as I've scoped the receive line when I send data. I also set the RX pin as a GPIO and was able to scope the pin toggling. I don't think its a baud rate issue since i can send data and read it on the other side.
Even when I send data the Line Status Register(LSR) doesn't show any change on the RDR bit (ie that its empty).
I've scoured the user manual and cant find anything... I think Im not setting a register correctly but don't know which one. My USART0 registers are all zero except for:
IIR = 0x01
LCR= 0x3
FDR=0xa1
OSR=0xf0
TER=0x1
My code is as follows:
// Set Pin mode to RX
LPC_SCU->SFSP2_1 = (0x07 & 0x01);
//Condfigure Uart0 with fucntions from lpc18xx_uart.h
UART_CFG_Type uartCfg;
UART_ConfigStructInit(&uartCfg);
UART_Init(LPC_USART0,&uartCfg);
while(1) {
lsr= UART_GetLineStatus(LPC_USART0);
a= UART_ReceiveByte(LPC_USART0);
//check if has received anything on LSR RBR bit
b=lsr & 1;
if(b)
{
//send data back
UART_TxCmd(LPC_USART0,ENABLE);
UART_SendByte(LPC_USART0,a);
}
}
Any help would be greatly appreciated.
Thanks