<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > S3C2410串口波特率的計算

S3C2410串口波特率的計算

作者: 時(shí)間:2016-11-10 來(lái)源:網(wǎng)絡(luò ) 收藏
要正確計算串口波特率,首先要搞清楚芯片的時(shí)鐘工作原理,這部分在s3c2410/s3c2440datasheet上寫(xiě)的比較詳細,但對新手來(lái)說(shuō)結合thisway同志“s3c2410完全開(kāi)發(fā)流程”中的TIMER和CLOCK兩個(gè)實(shí)驗,邊做實(shí)驗邊看資料,更容易理解。

我這里只根據我的失敗經(jīng)驗談一下設置波特率寄存器UBRDIVn的值的計算要注意的一個(gè)問(wèn)題。

本文引用地址:http://dyxdggzs.com/article/201611/317242.htm

datasheet上UBRDIVn寄存器部分寫(xiě)著(zhù):

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

也就是說(shuō),只要知道這個(gè)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.是說(shuō)當用系統時(shí)鐘(system clock)時(shí)UART波特率最高可達到115200,但是如果用這個(gè)UEXTCLK(external clocks for the UART operation)串口外設時(shí)鐘,可以設置115200以上的波特率。

2. PCLK和FCLK/n

這里又分兩種情況:使用MPLL和不使用MPLL

我們知道s3c2410最高頻率可達266M,s3c2440最高頻率可達533M,而一般外接晶振只有幾十M,如何使幾十M變成幾百M呢?這就是MPLL的功勞了

s3c2410有兩個(gè)pll(phase locked loop,鎖相環(huán),在高頻中學(xué)過(guò),可以實(shí)現倍頻,s3c2410的高頻就是由此電路產(chǎn)生的)。其中一個(gè)是MPLL,M即為main,用來(lái)產(chǎn)生三種時(shí)鐘信號:Fclk(給CPU核供給時(shí)鐘信號,我們所說(shuō)的s3c2410的cpu主頻為200MHz,就是指的這個(gè)時(shí)鐘信號,相應的,1/Fclk即為cpu時(shí)鐘周期)、Hclk(為AHB bus peripherals供給時(shí)鐘信號,AHB為advanced high-performance bus)、Pclk(為APB bus peripherals供給時(shí)鐘信號,APB為advanced peripherals bus)。AHB和APB這兩種總線(xiàn)所連的外設是有區別的。AHB總線(xiàn)連接高速外設,低速外設則通過(guò)APB總線(xiàn)互連。顯然,對不同總線(xiàn)上的外設,應該使用不同的時(shí)鐘信號,AHB總線(xiàn)對應Hclk,APB總線(xiàn)對應Pclk。那么事先就應該弄清楚,每條總線(xiàn)對應的外設有那些,這樣在設置好時(shí)鐘信號后,對應外設的初始化的值就要依此而確定了。

當不使用MPLL(即不設置MPLLCON寄存器)時(shí),外部晶振直接作為系統時(shí)鐘。一般外部晶振有兩個(gè),一是用于系統時(shí)鐘,為12MHz(或其他,由具體板子決定);一個(gè)用于實(shí)時(shí)時(shí)鐘(RTC,real time clock,根據CPU的要求送出或設定時(shí)鐘、日歷的各種數據),為32.768KHz。此時(shí),PCLK即為12MHz。

當使用MPLL時(shí),要通過(guò)對寄存器MPLLCON和CLKDIVN的設置來(lái)得到FCLK、HCLK和PCLK。

得到這個(gè)UART clock(PCLK, FCLK/n or UEXTCLK ),根據公式

UBRDIVn = (int)( UART clock / ( buad rate x 16) ) –1

來(lái)計算就簡(jiǎn)單了。



關(guān)鍵詞: S3C2410串口波特

評論


技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>