lpcware

LPC800在30M情况下,设置串口波特率出错

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by malei222222 on Thu Dec 24 08:17:52 MST 2015
系统使用30M的速度,如下设置:
#define SYSPLLCTRL_Val        0x00000024
#define SYSAHBCLKDIV_Val      0x00000002

串口的设置如下:(SystemCoreClock = 30M,UART_BPS = 115200)

baudRateGenerator = SystemCoreClock / (16 * UART_BPS);
    err = SystemCoreClock - baudRateGenerator * 16 * UART_BPS;
    uart_fra_multiplier = (err * 0xFF) / (baudRateGenerator * 16 * UART_BPS);
    LPC_USART0->BRG = baudRateGenerator - 1;
    LPC_SYSCON->UARTFRGDIV = 0XFF;
    LPC_SYSCON->UARTFRGMULT = uart_fra_multiplier;
如上设置之后,串口输出会乱码,并不是115200,请问要如何设置,哪里的计算不对?

Outcomes