This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Getting LPC11C14 UART to transmit

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