简体   繁体   中英

raspberry pi uart baud rate locked at 9600

I have been using raspberry pi with a usb to rs232 converter but now I have to use Raspberry Pi's UART pins but I have such a silly problem.

I am using termios.h library in C ( http://en.wikibooks.org/wiki/Serial_Programming/termios ) and it works very well with converter but when I use UART pins, while I am setting baud rate as

cfsetospeed(&tio,B115200);            // 115200 baud
cfsetispeed(&tio,B115200);            // 115200 baud

baud rate still works at 9600. Is there anouther setting that I have to do with termios library ? If not what should I have to do to change the baudrate ?

Also I have tried with baudrate 4800 and it still works with 9600 when I use UART but with the usb to rs232 converter there is no porblem.

I am using the library

https://github.com/irukeru/TermiosSerialCom

that I have modified and there is no problem with other devices.

Don't see an answer to the OP in this thread, so since I spent much time looking for it and for the sake of public knowledge, here's how to change the default UART baud rate on a Raspberry Pi: Simply edit the file /boot/config.txt to add the following line:

init_uart_baud=115200

You will need root permissions to do so, so don't forget to either start with sudo su and then nano /boot/config.txt or simply sudo nano /boot/config.txt and add the specific line at the end. Then reboot ( sudo reboot ).

For more /boot/config.txt configuration parameters, check the following link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM