ESP8266 Developer Zone The Official ESP8266 Forum 2015-02-05T16:41:18+08:00 https://bbs.espressif.com:443/feed.php?f=61&t=182 2015-02-05T16:41:18+08:00 2015-02-05T16:41:18+08:00 https://bbs.espressif.com:443/viewtopic.php?t=182&p=643#p643 <![CDATA[How to change UART baudrate ? - 修改 UART 波特率]]> :idea: :idea:
ESP8266 default baudrate is 74880, and output from UART0, if we want to change it.
For example, change baudrate to 115200.

call uart_init(115200, 115200); in user_init.

Code:

void ICACHE_FLASH_ATTR
uart_init(UartBautRate uart0_br, UartBautRate uart1_br)
{
    // rom use 74880 baut_rate, here reinitialize
    UartDev.baut_rate = uart0_br;
    uart_config(UART0);
    UartDev.baut_rate = uart1_br;
    uart_config(UART1);
    ETS_UART_INTR_ENABLE();

    // install uart1 putc callback
    os_install_putc1((void *)uart1_write_char);
}


Notice that the last sentence in uart_init, os_install_putc1((void *)uart1_write_char) is going to change "os_printf" to output from UART1.
So if you don't want to use UART1, please delete the last sentence in uart_init.

Code:

 //os_install_putc1((void *)uart1_write_char);


ESP8266 默认波特率为 74880 ,从 UART0 输出。
如果我们想修改波特率,例如改为 115200。

请在 user_init 中调用 uart_init(115200, 115200);

uart_init 中的最后一句 os_install_putc1((void *)uart1_write_char) 设置将 "os_printf" 的打印信息从 UART1 输出 .
如果您不需要使用 UART1,将这最后一句注释掉即可。

Thanks for your interest in ESP8266 !

Statistics: Posted by ESP_Faye — Thu Feb 05, 2015 4:41 pm


]]>