在SYSBIOS中调用UART driver进行UART通讯时,发现在PC端无法正常接收信息。用示波器检测发现波特率并不等于设置的115200,实际只有12500。主频率使用BIOS_setCpuFreq(&freq)设置成1000MHz。下面代码还需要初始化什么来匹配好波特率呢?
char echoPrompt[] = "12345";
UART_init();
UART_Params_init(¶ms);
params.baudRate = 115200;
params.writeDataMode = UART_DATA_BINARY;
params.readDataMode = UART_DATA_BINARY;
params.readReturnMode = UART_RETURN_FULL;
params.readEcho = UART_ECHO_OFF;
uart_handle = UART_open(UART_INSTANCE, ¶ms);
if (!uart_handle) {
System_printf("UART did not open");
}
int ret = UART_write(uart_handle,echoPrompt,sizeof(echoPrompt));
System_printf("The UART wrote %d bytes\n", ret);
Shine:
BIOS_setCpuFreq()函数不会去改变CPU主频,只是告诉bios内核CPU freq是多少。
可以去GEL文件中修改CPU主频到1GHz。