Hi
This is my first time getting into NXP MCU, I have NXP LPC11C14 Cortex-M0 MCU trying to get its UART peripheral to transmit a simple character. I followed the steps in user manual (UM10398) but still having trouble.
#include "LPC11xx.h" // Device header int main () { char ch = 'p'; uint32_t tick = 0; SystemCoreClockUpdate(); /* enable clock for I2C, GPIO, UART, ADC and IOCON */ LPC_SYSCON->SYSAHBCLKCTRL |= ((1UL << 5) | (1UL << 6) | (1UL << 12) | (1UL << 13) | (1UL << 16) ); /* Setting up IO for LED */ LPC_IOCON->PIO1_9 |= ((0UL << 0) | (3UL << 6) ); LPC_GPIO1->DIR |= 0x200UL; LPC_GPIO1->DATA |= 1UL << 9; /* UART Configuration */ /* Select RXD and TXD pin's function */ LPC_IOCON->PIO1_6 |= (1UL << 0); LPC_IOCON->PIO1_7 |= (1UL << 0); /* peripheral clock, 12MHz divided by 1 = 12MHz */ LPC_SYSCON->UARTCLKDIV = 1; /* UART format config */ LPC_UART->LCR |= ((3UL << 0) | /* 8-bit character length */ (1UL << 2) | /* 1 stop bit */ (0UL << 3) | /* disable parity gen and chk */ (0UL << 6) | /* disable break control */ (1UL << 7)); /* enable access to Divisor Latch */ /* baud rate config for 115200kbps, DLAB (LCR:7) must be set */ LPC_UART->DLM = 0; LPC_UART->DLL = 4; /* Use DIVADDVAL and MULVAL from user manual eg. (13.5.15.1.2) */ LPC_UART->FDR |= ((5UL << 0) | (8UL << 4)); /* enable TX and RX FIFO and reset them */ LPC_UART->FCR |= ((1UL << 0) | /* FIFOEN */ (1UL << 1) | /* RXFIFORES */ (1UL << 2) | /* TXFIFORES */ (1UL << 6)); /* RXTL */ /* disable access to Divisor Latch */ LPC_UART->LCR |= (0UL << 7); while (1) { tick++; if(tick >= 1000000) { tick = 0; LPC_UART->THR = ch; } } }
The RS232 adapter is working as I can send data from a PIC32 microcontroller. Have I missed something while configuring the UART peripheral?
Thank you Eric
Oops, that was an oversight. The MCU is now transmitting, but for some reason the bitrate was set to a strange 480,769kbps (judging the bit period from an oscilloscope) despite using the user manual's 115,200kbps settings which also uses 12MHz crystal with 1 as PCLK for UART clock. I'll have to figure that out.
Thank you for your help!
Maybe LPC11C14 is running at 50MHz, not 12MHz, with PLL enabled.