s3c2410/s3c2440串口波特率的计算

本文介绍了S3C2410/S3C2440芯片串口波特率的计算方法,包括UBRDIVn寄存器设置和不同时钟源(UEXTCLK、PCLK、FCLK/n)的影响。通过计算公式(UBRDIVn = (int)(UART clock / (baud rate * 16)) - 1)来确定波特率,同时讲解了MPLL的作用以及不使用MPLL时外部晶振作为系统时钟的情况。
摘要由CSDN通过智能技术生成

  s3c2410/s3c2440串口波特率的计算

要正确计算串口波特率,首先要搞清楚芯片的时钟工作原理,这部分在s3c2410/s3c2440datasheet上写的比较详细,但对新手来说结合thisway同志“s3c2410完全开发流程”中的TIMER和CLOCK两个实验,边做实验边看资料,更容易理解。

我这里只根据我的失败经验谈一下设置波特率寄存器UBRDIVn的值的计算要注意的一个问题。

datasheet上UBRDIVn寄存器部分写着:

UART BAUD RATE DIVISOR REGISTER
There are three UART baud rate divisor registers including UBRDIV0, UBRDIV1 and UBRDIV2 in the UART block.
The value stored in the baud rate divisor register (UBRDIVn), is used to determine the serial Tx/Rx clock rate (baudrate) as follows:
UBRDIVn = (int)( UART clock / ( buad rate x 16) ) –1
( UART clock: PCLK, FCLK/n or UEXTCLK )
Where, UBRDIVn should be from 1 to (216-1), but can be set zero only using the UEXTCLK which should be smaller than PCLK.
For example, if the baud-rate is 115200 bps and UART clock is 40 MHz, UBRDIVn is:
UBRDIVn = (int)(40000000 / (115200 x 16) ) -1
= (int)(21.7) -1 [round to the nearest whole number]
= 22 -1 = 21

也就是说,只要知道这个UART clock 就计算出UBRDIVn 的值,下面分别讲:

1. UEXTCLK

查手册:The UART can support bit rates up to 115.2K bps using system clock. If an external device provides the UART with UEXTCLK, then the UART can operate at higher speed.是说当用系统时钟(system clock)时UART波特率最高可达到115200,但是如果用这个UEXTCLK(external clocks for the UART operation)串口外设时钟,可以设置115200以上的波特率。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值