串口波特率默认为2400,修改成其他波特率方法如下:
DebugInit(UART_BUF_SIZE_BYTES_32, UartDataRxCallback, NULL);
/*主要添加下面两条*/
UartConfig(0x01d9,0);//115200 其他波特率值如下。
UartConfig(0x01d9,0);//115200 其他波特率值如下。
UartEnable(TRUE);//uartconfig设置完会默认把串口关闭,所以要重新使能串口。
/* UART Rx threshold is set to 1,
* so that every byte received will trigger the rx callback.
*/
UartRead(1, 0);
波特率值:
* - UART_RATE_2K4 = 0x000a
* - UART_RATE_9K6 = 0x0028
* - UART_RATE_19K2 = 0x004e
* - UART_RATE_38K4 = 0x009e
* - UART_RATE_57K6 = 0x00eb
* - UART_RATE_115K2 = 0x01d9
* - UART_RATE_230K4 = 0x03af
* - UART_RATE_460K8 = 0x0760
* - UART_RATE_921K6 = 0x0ebf
* - UART_RATE_1382K4 = 0x161f
* - UART_RATE_1843K2 = 0x1d7e
* - UART_RATE_2764K8 = 0x2c3d
* - UART_RATE_3686K4 = 0x3afc
* - UART_RATE_9K6 = 0x0028
* - UART_RATE_19K2 = 0x004e
* - UART_RATE_38K4 = 0x009e
* - UART_RATE_57K6 = 0x00eb
* - UART_RATE_115K2 = 0x01d9
* - UART_RATE_230K4 = 0x03af
* - UART_RATE_460K8 = 0x0760
* - UART_RATE_921K6 = 0x0ebf
* - UART_RATE_1382K4 = 0x161f
* - UART_RATE_1843K2 = 0x1d7e
* - UART_RATE_2764K8 = 0x2c3d
* - UART_RATE_3686K4 = 0x3afc