51单片机传输时改变波特率
时间: 2023-09-15 18:21:44 浏览: 199
在51单片机中,要改变串口通信的波特率,需要修改串口通信的波特率发生器寄存器(Baudrate Generator Register,缩写为:Baud)的值。具体步骤如下:
1.计算新的波特率发生器的值,公式如下:波特率发生器的值 = 定时器时钟频率 / (12 * 波特率) - 1。
2.将计算出的波特率发生器的值写入到波特率发生器寄存器(Baud)中。
3.重新启动串口通信,使新的波特率生效。
需要注意的是,修改波特率时,必须要保证发送和接收端的波特率是一致的,否则通信可能会出现错误。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)