Top Banner
微微微微微微 微微微 微微微 MSP430 MSP430 USCI USCI 微微 微微
22

第十章 MSP430 的 USCI 模組

Jan 05, 2016

Download

Documents

miya

第十章 MSP430 的 USCI 模組. USCI 簡介. UART. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 第十章 MSP430 的 USCI 模組

微處理機系統

第十章第十章MSP430MSP430 的的 USCIUSCI 模組模組

Page 2: 第十章 MSP430 的 USCI 模組

USCIUSCI 簡介簡介

Page 3: 第十章 MSP430 的 USCI 模組

UARTUART 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 http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter

Page 4: 第十章 MSP430 的 USCI 模組

UARTUART 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 http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter

Page 5: 第十章 MSP430 的 USCI 模組

UART in MSP430UART in MSP430UART Mode

Page 6: 第十章 MSP430 的 USCI 模組

UART in MSP430UART in MSP430

Page 7: 第十章 MSP430 的 USCI 模組

UARTUART 通訊通訊 UARTUART01.C01.C以示波器觀察 Tx 訊號變化

Page 8: 第十章 MSP430 的 USCI 模組

UARTUART01.C01.C0x01

0x03

0x05

0x50

0x80Why??

Page 9: 第十章 MSP430 的 USCI 模組

UARTUART02.C02.C由 Rx 接收資料 兩個人一組,一位執行 UART_01

發送資料,另一位執行 UART_02接收資料觀察 UCA0RXBUF 或value 的值

UART_01(Transmitter)

Tx-Rx-

GND-

UART_02(Receiver)

-Rx-Tx-GND

上述哪一條線可拿掉而不影響結果 ??Why?

Page 10: 第十章 MSP430 的 USCI 模組

UARTUART03.C03.CRx 之中斷 (Interrupt)

如左圖設定觀察點,將 Tx 連接至自己的 Rx ,觀察程式進行及 value值的變化

UART_03Tx-Rx-

GND-

Page 11: 第十章 MSP430 的 USCI 模組

UARTUART04.C04.C與 PC 連結 以麵包板完成所需電路

MSP430Rx(P1.1)-

GND-

將電路連接至 PC 的 RS232 後,開啟超級終端機,設定 9600bps 傳輸 ( 硬體控制 - 無 ) ,由鍵盤輸入字元,觀察 MCU 接收到的值

PCRS232

RS232Driver

MCUUART

線材: 5 母 5公

Page 12: 第十章 MSP430 的 USCI 模組

UARTUART04.C04.C按鍵盤’ 1’(注意電壓的不同 )

MSP430Rx(P1.1)-

GND-

PCRS232

RS232Driver

MCUUART

PC 端傳來的原始訊號

轉換後傳至 MCU 的訊號

如前一頁,請更改程式與 PC 端設定,修改傳輸速度為 19200bps ,以示波器觀察波型變化。

Page 13: 第十章 MSP430 的 USCI 模組

UARTUART05.C05.C試由超級終端機輸入 1 與 2 觀察實驗板上 LED 燈變化

MSP430Rx(P1.1)-

GND-

PCRS232

RS232Driver

MCUUART

試著更改程式,當輸入1-9 的字元時,可根據輸入字元,變化 LED 閃爍次數。 (Hint:’1’ 的 ASCII 碼為 49)

Page 14: 第十章 MSP430 的 USCI 模組

UARTUART06.C06.C試由超級終端機觀察由實驗板傳來的字元

MSP430Tx(P1.2)-

GND-

PCRS232

RS232Driver

MCUUART

http://en.wikipedia.org/wiki/File:ASCII_Code_Chart.svg

試更改程式,只傳大寫的 A 至Z 字元

Page 15: 第十章 MSP430 的 USCI 模組

UARTUART07.C07.CMSP430Tx(P1.2)-

GND-

PCRS232

RS232Driver

MCUUART

試由超級終端機觀察由實驗板傳來的字元

Page 16: 第十章 MSP430 的 USCI 模組

UARTUART08.C08.C開啟 SerialRead01.VI 觀察傳來的溫度值變化

MSP430Tx(P1.2)-

GND-

PCRS232

RS232Driver

MCUUART

Page 17: 第十章 MSP430 的 USCI 模組

UARTUART09.C09.C

該程式碼可傳輸溫度數據自 Tx 傳出,並由 Rx 接收。( 同學可試著傳給別人,或是傳給自己 ) 。然而, AD 轉換的結果為10bits ,也就是說,每筆數據均會大於 1byte ,應該如何傳輸 ??

UART_09Tx-Rx-

GND-

Page 18: 第十章 MSP430 的 USCI 模組

UARTUART09-1.C09-1.C大於 1byte 之數據傳輸

UART_09Tx-Rx-

GND-

Page 19: 第十章 MSP430 的 USCI 模組

UARTUART09-1.C09-1.C大於 1byte 之數據傳輸

ADC10MEM 0000 00XX XXXX XXXX 2 bytes

000X XXXX send-h

100X XXXX send-l

000X XXXX get-h

100X XXXX get-l

0000 00XX XXXX XXXX result

包裝包裝

重組重組

Page 20: 第十章 MSP430 的 USCI 模組

UARTUART09-1.C09-1.C大於 1byte 之數據傳輸 ( 資料包裝 )

ADC10MEM 0000 00XX XXXX XXXX 2 bytes

000X XXXX send-h

100X XXXX send-l

ADC10MEM > > 5 ( 右移 5bits)

資料順序

0x001F0x001F & ADC10MEM

資料順序

MASK

+ 0x80 + 0x80 1 1000 0 0 0 0

資料順序觀察 ADCMEM, send_h, send_l 三個值之間的關係 (binary 模式 )

…XX XXXX XXXX0001 0001 11 11 11 1 1

& &

000X XXXX 000X XXXX

Page 21: 第十章 MSP430 的 USCI 模組

UARTUART09-1.C09-1.C大於 1byte 之數據傳輸 ( 資料重組 )

(unsigned int)(get_h << 5 ) 左移 5bits

0000 00XX XXX0 0000

觀察 ADCMEM, send_h, send_l, get_h, get_l, result 值之間的關係(binary 模式 )

000X XXXX get-h

100X XXXX get-l

(unsigned int)(get_l & 0x1F0x1F ) 以 mask 取值並去除資料順序編碼

100X XXXX

0001 0001 11 11 11 1 1 & &

000X XXXX 000X XXXX

0000 00XX XXXX XXXX

0000 00XX XXX0 0000

0000 0000 000X XXXX + +

Page 22: 第十章 MSP430 的 USCI 模組

UARTUART09-1.C09-1.C大於 1byte 之數據傳輸UART_09

Tx-Rx-

GND-

觀察資料發收狀況程式開始時先拔除接線 先發送 send_h 完畢後,再接線 接著發送 send_l 觀察中斷程式是否有處理資料 ? 再繼續發送 send_h 及 send_l ,觀察中斷程式是否有處理資料 ?