lpcware

UART RS232 Problem, LPC11C12

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by ctchen on Fri Jul 24 20:45:12 MST 2015
I have a problem that UART(RS232) transmission doesn’t normal operation.
Namely, garbage value is printed on console window of PC.
The environment of my development is…
(1) MPU : LPC11C12
(2) LPCXpress 7.8
(3) J-link(segger)

I know why this problem is occurred and how this problem is solved.
Can you advise me?

* Source code
void UARTInit()
{
    LPC_IOCON->PIO1_7 &= ~0x07;
    LPC_IOCON->PIO1_7 |= 0x01;              //UART TXD
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12);
    LPC_SYSCON->UARTCLKDIV = 0x01 ;

// BAUDRATE 115200
    LPC_UART->LCR = 0x83; //DLAB=1 to get access to baud dividers
                                              //Data bit : 8bit, Stop bit : 1bit, Parity : None
    LPC_UART->DLM = 0;
    LPC_UART->DLL = 4;
    LPC_UART->FDR = 0x85; // 12MHz, 115200: DIVADDVAL =5, MULVAL =8
    LPC_UART->LCR = 0x03; // DLAB = 0
    LPC_UART->FCR = 0x07; // Enable and reset TX and RX FIFO.
}

int main (void)
{
    LPC_SYSCON->SYSPLLCLKSEL = 0x01 ; // 12MHz, System oscillator
    LPC_SYSCON->MAINCLKSEL= 0x01 ; // 12MHz, Input clock to system PLL
    Unsigned char data = ‘A’ ;
    UARTInit() ;
    while (1)
    {
        while (!(LPC_UART->LSR & 0x40)) ;
LPC_UART->THR = data ;
    }
}

Outcomes