AnsweredAssumed Answered

LPC18xx UART0 cannot work

Question asked by Yuanbin Zhou on Apr 24, 2017
Latest reply on Jun 29, 2017 by Kerry Zhou

Hi all,

 

I am currently using LPC1837 processor in my project and try to use UART0 to debug . Unfortunatelly it cannot work. In my project, I use uart0 to send messages to my computer visa usb-uart cable and initialize the uart register as below:

LPC_CCU1->CLK_M3_GPIO_CFG |= 0x01;
while (!(LPC_CCU1->CLK_M3_GPIO_STAT & 0x01));

/* Enable USART0 peripheral clock */
LPC_CCU2->CLK_APB0_USART0_CFG |= 0x01;
while (!(LPC_CCU2->CLK_APB0_USART0_STAT & 0x01));

/* Enable USART0 register interface clock */
LPC_CCU1->CLK_M3_USART0_CFG |= 0x01;
while (!(LPC_CCU1->CLK_M3_USART0_STAT & 0x01));

/* Init GPIO pins */
LPC_SCU->SFSP2_0 = (1 << 6) | /* Input buffer enabled */
(1 << 4) | /* Pull-up disabled */
(1 << 0) ; /* Pin P2_0 used as U0_TXD */

LPC_SCU->SFSP2_1 = (1 << 6) | /* Input buffer enabled */
(1 << 4) | /* Pull-up disabled */
(1 << 0) ; /* Pin P2_1 used as U0_RXD */

/* Init USART0 */
uart->USART->LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
uart->USART->DLL = 0x06; /* 115200 Baudrate @ 12 MHz IRC */
uart->USART->DLM = 0x00;
uart->USART->FDR = 0xC1;
uart->USART->LCR = 0x03; /* DLAB = 0 */
/* preemption = 1, sub-priority = 1 */
NVIC_SetPriority(uart->USART_IRQn, ((0x01 << 3) | 0x01));

/* Enable Interrupt for UART channel */
NVIC_EnableIRQ(uart->USART_IRQn);

to send data:

while (!(uart->USART->LSR & 0x20));
uart->USART->THR = c;

c here stands for data want to be sent.

Platform:Keil Uvision4

 

Outcome:No any messages in the ternimal.

It is really strange that there is not any messages in the ternimal since the function of GPIO has been correctly set. What is wrong with my codes?

Outcomes