第十章 msp430 的 usci 模組
DESCRIPTION
第十章 MSP430 的 USCI 模組. USCI 簡介. UART. - PowerPoint PPT PresentationTRANSCRIPT
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
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
UARTUART02.C02.C由 Rx 接收資料 兩個人一組,一位執行 UART_01
發送資料,另一位執行 UART_02接收資料觀察 UCA0RXBUF 或value 的值
UART_01(Transmitter)
Tx-Rx-
GND-
UART_02(Receiver)
-Rx-Tx-GND
上述哪一條線可拿掉而不影響結果 ??Why?
UARTUART04.C04.C與 PC 連結 以麵包板完成所需電路
MSP430Rx(P1.1)-
GND-
將電路連接至 PC 的 RS232 後,開啟超級終端機,設定 9600bps 傳輸 ( 硬體控制 - 無 ) ,由鍵盤輸入字元,觀察 MCU 接收到的值
PCRS232
RS232Driver
MCUUART
線材: 5 母 5公
UARTUART04.C04.C按鍵盤’ 1’(注意電壓的不同 )
MSP430Rx(P1.1)-
GND-
PCRS232
RS232Driver
MCUUART
PC 端傳來的原始訊號
轉換後傳至 MCU 的訊號
如前一頁,請更改程式與 PC 端設定,修改傳輸速度為 19200bps ,以示波器觀察波型變化。
UARTUART05.C05.C試由超級終端機輸入 1 與 2 觀察實驗板上 LED 燈變化
MSP430Rx(P1.1)-
GND-
PCRS232
RS232Driver
MCUUART
試著更改程式,當輸入1-9 的字元時,可根據輸入字元,變化 LED 閃爍次數。 (Hint:’1’ 的 ASCII 碼為 49)
UARTUART06.C06.C試由超級終端機觀察由實驗板傳來的字元
MSP430Tx(P1.2)-
GND-
PCRS232
RS232Driver
MCUUART
http://en.wikipedia.org/wiki/File:ASCII_Code_Chart.svg
試更改程式,只傳大寫的 A 至Z 字元
UARTUART09.C09.C
該程式碼可傳輸溫度數據自 Tx 傳出,並由 Rx 接收。( 同學可試著傳給別人,或是傳給自己 ) 。然而, AD 轉換的結果為10bits ,也就是說,每筆數據均會大於 1byte ,應該如何傳輸 ??
UART_09Tx-Rx-
GND-
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
包裝包裝
重組重組
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
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 + +