LPC4078 UART1 RXD PROBLEM

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

LPC4078 UART1 RXD PROBLEM

1,308 Views
istvanmate
Contributor II

I built 2 prototype boards using the LPC 4078 and when I run the example code periph_uart_rb ( for Embedded Artists' LPC4088 Developer's Kit:)  in LPCXpresso it transmits the string "LPC17xx/40xx UART example using ring buffers \r\n"; and "Press a key to echo it back or ESC to quit\r\n"to the PC but it won't receive anything sent from the PC.

Here is the code modified to use UART1:

#if defined(BOARD_EA_DEVKIT_1788) || defined(BOARD_EA_DEVKIT_4088)
#define UART_SELECTION LPC_UART1
#define IRQ_SELECTION UART1_IRQn
#define HANDLER_NAME UART1_IRQHandler
#elif defined(BOARD_NXP_LPCXPRESSO_1769)
#define UAR3T_SELECTION LPC_UART3
#define IRQ_SELECTION UART3_IRQn
#define HANDLER_NAME UART3_IRQHandler
#else
#error No UART selected for undefined board
#endif


/* Transmit and receive ring buffers */
STATIC RINGBUFF_T txring, rxring;

/* Transmit and receive ring buffer sizes */
#define UART_SRB_SIZE 128 /* Send */
#define UART_RRB_SIZE 32 /* Receive */

/* Transmit and receive buffers */
static uint8_t rxbuff[UART_RRB_SIZE], txbuff[UART_SRB_SIZE];

const char inst1[] = "LPC17xx/40xx UART example using ring buffers \r\n";
const char inst2[] = "Press a key to echo it back or ESC to quit\r\n";

void HANDLER_NAME(void)
{
/* Want to handle any errors? Do it here. */

/* Use default ring buffer handler. Override this with your own
code if you need more capability. */
Chip_UART_IRQRBHandler(UART_SELECTION, &rxring, &txring);
}

int main(void)
{

uint8_t key;
int bytes;

SystemCoreClockUpdate();
Board_Init();
//Board_UART_Init(UART_SELECTION);

/******** Set up UART1 on Port 2 pin 0 TX and Pin 1 RX ****/
Chip_IOCON_PinMuxSet(LPC_IOCON, 2, 0, (IOCON_FUNC2 | IOCON_MODE_INACT));
Chip_IOCON_PinMuxSet(LPC_IOCON, 2, 1, (IOCON_FUNC2 | IOCON_MODE_INACT));
//Board_LED_Set(0, false);

/* Setup UART for 115.2K8N1 */
Chip_UART_Init(UART_SELECTION);
Chip_UART_SetBaud(UART_SELECTION, 115200);
Chip_UART_ConfigData(UART_SELECTION, (UART_LCR_WLEN8 | UART_LCR_SBS_1BIT));
Chip_UART_SetupFIFOS(UART_SELECTION, (UART_FCR_FIFO_EN | UART_FCR_TRG_LEV0));
Chip_UART_TXEnable(UART_SELECTION);


/* Before using the ring buffers, initialize them using the ring
buffer init function */
RingBuffer_Init(&rxring, rxbuff, 1, UART_RRB_SIZE);
RingBuffer_Init(&txring, txbuff, 1, UART_SRB_SIZE);

/* Reset and enable FIFOs, FIFO trigger level 3 (14 chars) */
Chip_UART_SetupFIFOS(UART_SELECTION, (UART_FCR_FIFO_EN | UART_FCR_RX_RS |
UART_FCR_TX_RS | UART_FCR_TRG_LEV0));

/* Enable receive data and line status interrupt */
Chip_UART_IntEnable(UART_SELECTION, (UART_IER_RBRINT | UART_IER_RLSINT));

/* preemption = 1, sub-priority = 1 */
NVIC_SetPriority(IRQ_SELECTION, 1);
NVIC_EnableIRQ(IRQ_SELECTION);

/* Send initial messages */
Chip_UART_SendRB(UART_SELECTION, &txring, inst1, sizeof(inst1) - 1);
Chip_UART_SendRB(UART_SELECTION, &txring, inst2, sizeof(inst2) - 1);


// Poll the receive ring buffer for the ESC (ASCII 27) key
key = 0;
while (key != 27)
{
bytes = Chip_UART_ReadRB(UART_SELECTION, &rxring, &key, 1);
if(bytes != 0)
{
Chip_UART_SendByte(UART_SELECTION, key);
}

}


/* DeInitialize UART0 peripheral */
NVIC_DisableIRQ(IRQ_SELECTION);
Chip_UART_DeInit(UART_SELECTION);

return 1;
}

I have to use UART1 instead of UART0 given in the example so I changed all references to UART1 and the transmit part works.

I am able to verify the incoming data on Pin59 P2[1] with the oscilloscope but when I look in the peripheral window UART1 -LSR - RDR shows empty. I also put a break point in the UART1 ISR but it never reaches it - the micro is not seeing the incoming data on UART1.

Both prototype boards behave the same way so it is highly unlikely Pin 59 is blown on both boards. I hope somebody could help me figure this out.

Using: LPCXpresso v7.9.0 [Build 455] [2015-07-23] 

Labels (1)
0 Kudos
2 Replies

786 Views
jeremyzhou
NXP Employee
NXP Employee

Hi ISTVAN MATE,

Thank you for your interest in NXP Semiconductor products and 
the opportunity to serve you.
I don't have the LPC4088 OEM Board on hand, however I have the LPC1788 OEM Board and LPC4088 is compatible with LPC1788 except that the Cortex-M core.
I use your code, but the issue is not happened and the code work well.
So I'd highly recommend you to check the value of USART1 registers in LPCXpresso IDE when debugging the code, I think it will help you figure the root cause of the issue.
2017-06-06_15-45-43.jpg
Have a great day,

TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

786 Views
istvanmate
Contributor II

Thanks for checking it out. It narrows it down and helps me quite a bit with these crazy deadlines.