1 / 25

串列 I/O(UART)

串列 I/O(UART). 20010/12/08. What is UART. 個人電腦上所使用 RS-232 通訊介面上的非同步串列埠,能將平行格式的資料轉換成一系列循序的資料。 串列埠和平行埠兩者最大的不同點乃在於其傳遞資料的方式 : 平行埠:資料以 byte 為單位,同時由平行埠傳送出去。 串列埠:資料會轉換成 連續的 bit ,然後依序由埠送出,接收端收集這些資料後再將其合成為原來的 byte 。 RS-232 用來作序列傳輸的控制晶片稱 UART (Universal Asynchronous Receiver Transmitter). 實習基礎.

licia
Télécharger la présentation

串列 I/O(UART)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 串列I/O(UART) 20010/12/08

  2. What is UART • 個人電腦上所使用 RS-232 通訊介面上的非同步串列埠,能將平行格式的資料轉換成一系列循序的資料。 • 串列埠和平行埠兩者最大的不同點乃在於其傳遞資料的方式: • 平行埠:資料以byte為單位,同時由平行埠傳送出去。 • 串列埠:資料會轉換成連續的bit,然後依序由埠送出,接收端收集這些資料後再將其合成為原來的byte。 • RS-232 用來作序列傳輸的控制晶片稱 UART (Universal Asynchronous Receiver Transmitter)

  3. 實習基礎 • S3C4510B 提供了兩個獨立非同步串列I/O埠(UART0、UART1) • 重要特色包含: • 可規劃的鮑率。 • Infra-red (IR)傳送/接收。 • 各個frame可插入1或2個停止位元。 • 可選擇5位元,6位元,7位元或者是8位元的資料傳送。 • 同位(parity)檢查。 • 鮑率產生器可由內部系統時脈(MCLK)或是外部時脈(UCLK)來驅動 • 傳輸器(TX)和接收器(RX)各擁有資料緩衝暫存器和資料位移器

  4. 非同步傳輸的資料格式

  5. UART特殊暫存器

  6. UART線路控制暫存器

  7. UART狀態暫存器

  8. UART傳送緩衝暫存器

  9. UART接收緩衝暫存器

  10. 鮑率產生器 UART鮑率產生器電路圖

  11. UART鮑率除數暫存器 • UART鮑率除數暫存器 (UBRDIVn) [3:0]:鮑率除值CNT1 xxx0 = 除 1 xxx1 = 除 16 [15:4] :時間常數值CNT0

  12. UART鮑率計算範例 • MCLK2 = MCLK / 2 ;CNT1= 0 or 1 • Ex : BRGOUT = 19200 • (CNT1=0) • CNT0 = 50M/(32*19200) - 1 ≒ 80 •  CNT0 ≒ 80 •  UBRDIVx =0x500 • 若MCLK=50MHz,則MCLK2=25MHz 故最大BRGOUT = MCLK2/16(1.5625MHz)

  13. UART一般鮑率 設定CNT0與CNT1來決定鮑率值

  14. 電路圖 ARM CPU Module RS-232 Driver Serial Port

  15. 程式流程圖 開始 UART初始化 Q & A模組 END

  16. 超級終端機

  17. 程式說明

  18. console_init@console.c • int console_init(void) { //Line control register : Normal, No parity,1 stop,8 bits outl(0x03, ULCON0); //control register, receive interrupt and transmit interrupt outl(0x09, UCON0); //setting baud rate 19200 outl(0x500, UBRDIV0); //Wait until tx shifter is empty. while (!(inl(USTAT0) & 0x80)); return 0; }

  19. 終端機顯示畫面

  20. 可應用函式 • getch():讀取輸入的字元。 • putch():輸出字元。 • puts():輸出字串。

  21. 實習 • 實習一:當RS232傳輸線只能使用38400bps和7bit傳送時,使用原本的程式將會產生錯誤。修正使其資料可以和4510互傳。 • 實習二:承上題將UART0改成以UART1輸出。 • 實習三:參考console.c所提供的函式getch(),putch(), puts()做出如下圖效果(輸入&顯示自己的英文名字) (Hint : enter鍵的 ASCII code 為 0x0d)

  22. 實習一

More Related