AnsweredAssumed Answered

LPC1766 UART send garbled

Question asked by ma teng on Mar 16, 2019
Latest reply on Mar 18, 2019 by ma teng

My code is below, when i run this code, I received the data like the picture. Anyone can tell me why?

Receive baudrate is 9600. Use TTL-USB connect to my computer. 

int main(void)
{
uint32_t i,j, k=0;

SystemInit();
UART0_Init(9600);

UART0_SendString("hello world");
Delay(250);
}

#define FOSC                        12000000 

#define FCCLK                      (FOSC  * 8)

#define FCCO                       (FCCLK * 3)

#define FPCLK                      (FCCLK / 4)

void UART0_Init (uint32_t baudrate)
{
uint16_t usFdiv;
/* UART0 */
LPC_PINCON->PINSEL0 |= (1 << 4);
LPC_PINCON->PINSEL0 |= (1 << 6);

LPC_UART0->LCR = 0x83;
usFdiv = (FPCLK / 16) / baudrate;
LPC_UART0->DLM = usFdiv / 256;
LPC_UART0->DLL = usFdiv % 256;
LPC_UART0->LCR = 0x03;
LPC_UART0->FCR = 0x06;
}

 

Outcomes