1 / 26

第 9 章

第 9 章. 串列傳輸介面. 串列埠的硬體特性. SPCE061A 有兩個串列介面, 一個是具有同步時脈的 SIO , 另一個是無同步時脈的通用非同步串列介面 UART 。 SIO 串列設備共用時脈與資料匯流排接腳,其傳輸訊號包括讀 / 寫、位址與 8 位元資料,不同設備間可以靠著裝置事先定義的位址來識別。 UART 的資料同步是靠起始位元的脈波來完成,當資料傳送完畢,其後須有停止位元,用來與下一筆資料的起始位元隔離。 SIO 與 UART 接腳皆與 IOB 埠接腳共用. 串列埠接腳. SIO 的讀寫操作時序. 非同步串列傳輸格式. 串列埠控制的暫存器.

Télécharger la présentation

第 9 章

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. 第9章 串列傳輸介面

  2. 串列埠的硬體特性 • SPCE061A 有兩個串列介面, • 一個是具有同步時脈的 SIO, • 另一個是無同步時脈的通用非同步串列介面UART。 • SIO串列設備共用時脈與資料匯流排接腳,其傳輸訊號包括讀/寫、位址與8位元資料,不同設備間可以靠著裝置事先定義的位址來識別。 • UART的資料同步是靠起始位元的脈波來完成,當資料傳送完畢,其後須有停止位元,用來與下一筆資料的起始位元隔離。SIO與UART接腳皆與IOB埠接腳共用

  3. 串列埠接腳

  4. SIO 的讀寫操作時序

  5. 非同步串列傳輸格式

  6. 串列埠控制的暫存器

  7. UART相關暫存器 • P_UART_Command1 (寫) ($7021H) 規劃中斷方式、同位元 • P_UART_Command2 (讀/寫) ($7022H) 狀態 • P_UART_Data(讀/寫)($7023H) • P_UART_BaudScalarLow(讀/寫)($7024H) 速率 P_UART_BaudScalarHigh (讀/寫)($7025)

  8. P_SIO_Ctrl 暫存器

  9. P_SIO_Data 暫存器

  10. P_SIO_ Addr 暫存器群 P_SIO_ Addr_Low P_SIO_Addr_ Mid P_SIO_Addr_High

  11. P_SIO_Start /P_SIO_Stop P_SIO_Start P_SIO_Stop 向 P_SIO_Stop暫存器寫入任一數值,可以停止資料傳輸

  12. P_UART_Command1暫存器

  13. P_UART_Command2暫存器

  14. UART 錯誤原因及解決方法

  15. P_UART_Data暫存器

  16. P_UART_BaudScalar暫存器群 • UART 串列傳輸速率的計算公式如下: • Fosc=49.152 / 40.960 / 32.768 MHz時, 傳輸速率Baud= ( Fosc / 4 ) / Scale • Fosc=24.576 / 20.480 MHz時, 傳輸速率Baud= ( Fosc / 2 ) / Scale

  17. 24.576 / 49.152MHz 常用速率值

  18. 20.48 / 40.96MHz常用速率值

  19. 32.768 MHz 常用速率值

  20. SPCE061A 與 PC 連接圖

  21. SPR4096電路圖

  22. UART相關副程式1 void UART_Init() { char ch; // 注意: 特殊接腳時仍須設定GPIO暫存器, 否則可能因被強迫pull-high/low而不動作 *P_IOB_Dir=0x0400; // IOB10=output(TX), IOB7=input(RX) *P_IOB_Attrib=0x0480; // IOB10=not invert, IOB7=float *P_UART_Command1=0x20; // UART reset, 無同位元 *P_UART_Command1=0x00; //*P_UART_BaudScalarHigh=0x00; // Baud=115200bps //*P_UART_BaudScalarLow=0x6B; *P_UART_BaudScalarHigh=0x05; // Baud=9600bps *P_UART_BaudScalarLow=0x00; *P_UART_Command2=0x00C0; // 致能RX/TX ch = *P_UART_Data; // 清除緩衝區 }

  23. UART相關副程式2 char UART_GetByte() { while( ! (*P_UART_Command2 & 0x0080)) { //等待接收完畢 *P_Watchdog_Clear=C_WDTCLR; } return *P_UART_Data; }

  24. UART相關副程式3 void UART_SendByte(char ch) { while( !( *P_UART_Command2 & 0x0040)) { //等待前一次發射完畢 *P_Watchdog_Clear=C_WDTCLR; }

  25. uart.h • void UART_Init(); • char UART_GetByte(); • void UART_GetString(char *); • void UART_Put_Dec(unsigned int ); • void UART_SendByte(char); • void UART_SendString(char *); • void UART_SendString_no_linefeed(char *);

  26. 範例 • 利用副程式,兩數相加 • UART 控制LED花樣變化

More Related