Presentation is loading. Please wait.

Presentation is loading. Please wait.

第十章 MSP430的USCI模組.

Similar presentations


Presentation on theme: "第十章 MSP430的USCI模組."— Presentation transcript:

1 第十章 MSP430的USCI模組

2 USCI簡介

3 UART A Universal Asynchronous Receiver/Transmitter, abbreviated UART, is a type of "asynchronous receiver/transmitter", a piece of computer hardware that translates data between parallel and serial forms. UARTs are commonly used in conjunction with communication standards such as EIA, RS-232, RS-422 or RS-485. The universal designation indicates that the data format and transmission speeds are configurable and that the actual electric signaling levels and methods (such as differential signaling etc.) typically are handled by a special driver circuit external to the UART. -from Wiki

4 UART The Universal Asynchronous Receiver/Transmitter (UART) takes bytes of data and transmits the individual bits in a sequential fashion. At the destination, a second UART re-assembles the bits into complete bytes. Each UART contains a shift register, which is the fundamental method of conversion between serial and parallel forms. Serial transmission of digital information (bits) through a single wire or other medium is much more cost effective than parallel transmission through multiple wires. -from Wiki

5 UART in MSP430 UART Mode

6 UART in MSP430

7 UART通訊 UART01.C 以示波器觀察Tx訊號變化

8 UART01.C 0x01 0x03 0x05 0x50 0x80 Why??

9 UART02.C 由Rx接收資料 兩個人一組,一位執行UART_01發送資料,另一位執行UART_02接收資料觀察UCA0RXBUF或value的值 UART_01 (Transmitter) Tx- Rx- GND- UART_02 (Receiver) -Rx -Tx -GND 上述哪一條線可拿掉而不影響結果??Why?

10 UART03.C Rx之中斷(Interrupt) 如左圖設定觀察點,將Tx連接至自己的Rx,觀察程式進行及value值的變化
GND-

11 UART04.C 與PC連結 以麵包板完成所需電路 PC RS232 Driver MCU UART
線材:5母5公 MSP430 Rx(P1.1)- GND- 將電路連接至PC的RS232後,開啟超級終端機,設定9600bps傳輸(硬體控制-無),由鍵盤輸入字元,觀察MCU接收到的值

12 UART04.C 按鍵盤’1’(注意電壓的不同) PC端傳來的原始訊號 轉換後傳至MCU的訊號 PC RS232 Driver MCU
MSP430 Rx(P1.1)- GND- PC端傳來的原始訊號 轉換後傳至MCU的訊號 如前一頁,請更改程式與PC端設定,修改傳輸速度為19200bps,以示波器觀察波型變化。

13 UART05.C 試由超級終端機輸入1與2觀察實驗板上LED燈變化
PC RS232 Driver MCU UART 試由超級終端機輸入1與2觀察實驗板上LED燈變化 MSP430 Rx(P1.1)- GND- 試著更改程式,當輸入1-9的字元時,可根據輸入字元,變化LED閃爍次數。(Hint:’1’的ASCII碼為49)

14 UART06.C 試由超級終端機觀察由實驗板傳來的字元 試更改程式,只傳大寫的A至Z字元 PC RS232 Driver MCU UART
MSP430 Tx(P1.2)- GND- 試更改程式,只傳大寫的A至Z字元

15 UART07.C 試由超級終端機觀察由實驗板傳來的字元 PC RS232 Driver MCU UART MSP430 GND-
Tx(P1.2)- GND-

16 UART08.C 開啟SerialRead01.VI觀察傳來的溫度值變化 PC RS232 Driver MCU UART MSP430
Tx(P1.2)- GND-

17 UART09.C UART_09 Tx- Rx- GND-
然而,AD轉換的結果為10bits,也就是說,每筆數據均會大於1byte,應該如何傳輸??

18 UART09-1.C UART_09 Tx- Rx- GND- 大於1byte之數據傳輸

19 UART09-1.C ADC10MEM  0000 00XX XXXX XXXX  2 bytes 包裝 000X XXXX
send-h 100X XXXX send-l 000X XXXX get-h 100X XXXX get-l 重組 XX XXXX XXXX  result

20 UART09-1.C ADC10MEM  0000 00XX XXXX XXXX  2 bytes
ADC10MEM > > 5 (右移5bits) 000X XXXX send-h 資料順序 0x001F & ADC10MEM MASK 100X XXXX send-l & …XX XXXX XXXX 資料順序 000X XXXX + 0x80  資料順序 觀察ADCMEM, send_h, send_l 三個值之間的關係(binary模式)

21 UART09-1.C 000X XXXX get-h 100X XXXX get-l
大於1byte之數據傳輸(資料重組) 000X XXXX get-h 100X XXXX get-l (unsigned int)(get_h << 5 )  左移5bits XX XXX XX XXX + X XXXX (unsigned int)(get_l & 0x1F )  以mask取值並去除資料順序編碼 XX XXXX XXXX 觀察ADCMEM, send_h, send_l, get_h, get_l, result 值之間的關係(binary模式) 100X XXXX & 000X XXXX

22 UART09-1.C UART_09 Tx- Rx- 大於1byte之數據傳輸 GND- 觀察資料發收狀況
程式開始時先拔除接線 先發送send_h完畢後,再接線 接著發送send_l觀察中斷程式是否有處理資料? 再繼續發送send_h及send_l,觀察中斷程式是否有處理資料?


Download ppt "第十章 MSP430的USCI模組."

Similar presentations


Ads by Google