I do write a simple code to test UART0 of LPC4078 on our original board, but it does not work...
Codes for initialize UART0 are shown below:
void Uart0Init(void)
{
UART_CFG_Type UARTConfigStruct;
UART_FIFO_CFG_Type UARTFIFOConfigStruct;
UART_ConfigStructInit(&UARTConfigStruct);
UARTConfigStruct.Baud_rate = 115200;
UART_Init(UART_0, &UARTConfigStruct);
UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
UART_FIFOConfig(UART_0, &UARTFIFOConfigStruct);
UART_TxCmd(UART_0, ENABLE);
UART_IntConfig(UART_0, UART_INTCFG_RBR, ENABLE);
NVIC_SetPriority(UART0_IRQn, ((0x02<<3)|0x01));
NVIC_EnableIRQ(UART0_IRQn);
}
And the port 0.2 and 0.3 are set by codes below:
PINSEL_ConfigPin(0, 2, 1);
PINSEL_ConfigPin(0, 3, 1);
Based on the initialize code shown above, I tried to send some characters via ring buffer, but any characters sent to terminal.
I added "UART_SendByte(UART_0, 'A'); to simplify the debug work, but the result was same.
I believe "UART_SendByte" is very simple command and should be work, so there must be an error in my setup/initialization code...
The connection diagram of my debug environment are
PC USB
MCUXpresso ----- LPC-Link2 --------------- 4078board
Serial |
Tera Term ----- USB-Serial Converter ---------|
I did run the sample code "periph_uart_rb" and it was work, so I believe the hardware itself is correct.
Regards,
Hello Atsuki Nakano,
Please check whether enable the UART clock and GPIO (UART TX/RX) clock.
You can refer to the UART demo under LPCopen for LPC4088:
LPCOpen Software for LPC40XX | NXP
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Thank you Alice!
You mean, calling "Chip_Clock_EnablePeriphClock" from "Chip_UART_Init" in "uart_17xx_40xx.c"?
The "Chip_Clock_EnablePeriphClock" in "clock_17xx_40xx.c" and set the bit 3 of "LPC_SYSCTL->PCONP".
If so, "UART_Init" in "lpc_uart.c" calls "CLKPWR_ConfigPPWR" in "lpc_clkpwr.c" and certainly set the bit 3 of "LPC_SC->PCONP".
Finally, the value of "LPC_SC->PCONP" is "0x042887de", and the address of "LPC_SYSCTL->PCONP" and "LPC_SC->PCONP" is same, just "0x400fc000", so I think clock for UART is enabled.
Do you have any other idea or am I looking at the wrong place?
Regards,
Hello Atsuki Nakano,
The easy way is compare your code with example code.
Or you can directly config based on the example, thus can save your time to development.
BR
Alice
Hi Alice,
Thank you for your support.
I'll look into the differences between sample code and my one again.
Regards,
Atsuki