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

LPC11C14 problem with UART

I am not able to get any data from LPC11C14 uart port. I am using ISP UART programmer with Flash Magic, so I guess board should be fine. Unless there is something that needs to be grounded while using UART vs UART in ISP.

I have connect Logic Analyzer on P1.6 and P1.7 and I can see data flow when programming board, but I only get flat line while my program is running.

I dont have SWD so I cant check whether the configuration of registers are correct, but I run the program in simulator and it seems fine there.

main.cpp:

#include "LPC11xx.h"

void SystemInit ()
{
}

#define LSR_THRE        0x20

int main(void) {
  uint32_t Fdiv;
  uint32_t regVal;
  uint32_t baudrate = 19200;

  LPC_IOCON->PIO1_6 &= ~0x07;
  LPC_IOCON->PIO1_6 |= 0x01;
  LPC_IOCON->PIO1_7 &= ~0x07;
  LPC_IOCON->PIO1_7 |= 0x01;

  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12);
  LPC_SYSCON->UARTCLKDIV = 0x1;

  LPC_UART->LCR = 0x83;
  regVal = LPC_SYSCON->UARTCLKDIV;

  Fdiv = (((12000000UL*LPC_SYSCON->SYSAHBCLKDIV)/regVal)/16)/baudrate ;

  LPC_UART->DLM = Fdiv / 256;
  LPC_UART->DLL = Fdiv % 256;
  LPC_UART->LCR = 0x03;
  LPC_UART->FCR = 0x07;

    while(1){
        while ( !(LPC_UART->LSR & LSR_THRE) );
        LPC_UART->THR = 0x55;
        for (uint32_t i =0; i < 0xffff; i++);
    }
    return 0 ;
}

Have no clue what else to try ...

Parents Reply Children
No data