Making UART receive work on LPC18xx

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Making UART receive work on LPC18xx

590 Views
gvk51
Contributor III

Hi folks,

 

I am running the sample examples from lpcopen_2_18_lpcxpresso_nxp_lpcxpresso_1837, I see the UART receive function is not working. I have connected FTDI UART to usb cable, and connected the RX, TX & GND lines to U0_TXD, U0_RXD and GND lines.

 

I am able to see the following prints on Gtkterm/Cutecom

 

LPC18xx/43xx UART example using ring buffers

Press a key to echo it back or ESC to quit

 

But when I enter any key on the keyboard it is not able to receive.

 

Instead I went to use UART1, it worked fine with the following modifications.

Change it in uart_rb.c file of periph_uart_rb project

 

#if (defined(BOARD_NXP_LPCXPRESSO_4337) || defined(BOARD_NXP_LPCXPRESSO_1837))

#define LPC_UARTX   LPC_UART1
#define UARTx_IRQn  UART1_IRQn
#define UARTx_IRQHandlerUART1_IRQHandler

#endif

 

In board.c file I have added code to do pin muxing based on the requested UART port

 

void Board_UART_Init(LPC_USART_T *pUART)

{

    if (pUART == LPC_USART0) {

        Chip_SCU_PinMuxSet(0x6, 4, (SCU_MODE_INACT | SCU_MODE_FUNC2));                    /* P6,4 : UART0_TXD */

        Chip_SCU_PinMuxSet(0x2, 1, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC1));/* P2.1 : UART0_RXD */

    }else {

        Chip_SCU_PinMuxSet(0x1, 13, (SCU_MODE_INACT | SCU_MODE_FUNC1));                    /* P1.13 : UART1_TXD */

        Chip_SCU_PinMuxSet(0x1, 14, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC1));/* P1.14 : UART1_RXD */

    }

}

After the above modification I am able to send the data over UART, I have used U1_TXD, U1_RXD & GND pins on the RDK for connecting to FTDI UART to USB cable.

 

Thanks & Regards,

Vamshi G.

Labels (1)
Tags (1)
0 Kudos
1 Reply

301 Views
DavidS
NXP Employee
NXP Employee

Hi Vamshi G.,

You are very close to having it work.

In board.h please make following change and re-try:

#define DEBUG_UART LPC_UART1//DES was LPC_USART0

I used the periph_timers example and in timers.c I added the following to test receiving a character:

while(DEBUGIN() == EOF) {};//DES added to wait for character.

while (1) {
__WFI();
}

Regards,

David

0 Kudos