E N D
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 http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter
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 http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter
UART in MSP430 UART Mode
UART通訊UART01.C • 以示波器觀察Tx訊號變化
UART01.C • 0x01 • 0x03 • 0x05 • 0x50 • 0x80 Why??
UART02.C • 由Rx接收資料 • 兩個人一組,一位執行UART_01發送資料,另一位執行UART_02接收資料觀察UCA0RXBUF或value的值 UART_01 (Transmitter) Tx- Rx- GND- UART_02 (Receiver) -Rx -Tx -GND • 上述哪一條線可拿掉而不影響結果??Why?
UART03.C • Rx之中斷(Interrupt) • 如左圖設定觀察點,將Tx連接至自己的Rx,觀察程式進行及value值的變化 UART_03 Tx- Rx- GND-
UART04.C PC RS232 RS232 Driver MCU UART • 與PC連結 • 以麵包板完成所需電路 線材:5母5公 MSP430 Rx(P1.1)- GND- • 將電路連接至PC的RS232後,開啟超級終端機,設定9600bps傳輸(硬體控制-無),由鍵盤輸入字元,觀察MCU接收到的值
UART04.C PC RS232 RS232 Driver MCU UART • 按鍵盤’1’(注意電壓的不同) MSP430 Rx(P1.1)- GND- • PC端傳來的原始訊號 • 轉換後傳至MCU的訊號 • 如前一頁,請更改程式與PC端設定,修改傳輸速度為19200bps,以示波器觀察波型變化。
UART05.C PC RS232 RS232 Driver MCU UART • 試由超級終端機輸入1與2觀察實驗板上LED燈變化 MSP430 Rx(P1.1)- GND- • 試著更改程式,當輸入1-9的字元時,可根據輸入字元,變化LED閃爍次數。(Hint:’1’的ASCII碼為49)
UART06.C PC RS232 RS232 Driver MCU UART • 試由超級終端機觀察由實驗板傳來的字元 MSP430 Tx(P1.2)- GND- http://en.wikipedia.org/wiki/File:ASCII_Code_Chart.svg • 試更改程式,只傳大寫的A至Z字元
UART07.C PC RS232 RS232 Driver MCU UART • 試由超級終端機觀察由實驗板傳來的字元 MSP430 Tx(P1.2)- GND-
UART08.C PC RS232 RS232 Driver MCU UART • 開啟SerialRead01.VI觀察傳來的溫度值變化 MSP430 Tx(P1.2)- GND-
UART09.C UART_09 Tx- Rx- GND- • 該程式碼可傳輸溫度數據自Tx傳出,並由Rx接收。(同學可試著傳給別人,或是傳給自己)。 • 然而,AD轉換的結果為10bits,也就是說,每筆數據均會大於1byte,應該如何傳輸??
UART09-1.C UART_09 Tx- Rx- GND- • 大於1byte之數據傳輸
UART09-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
UART09-1.C • 大於1byte之數據傳輸(資料包裝) ADC10MEM 0000 00XX XXXX XXXX 2 bytes ADC10MEM>>5(右移5bits) 000X XXXX send-h 資料順序 0x001F & ADC10MEM MASK 100X XXXX send-l 0001 1111 & …XX XXXX XXXX 資料順序 000X XXXX + 0x80 1000 0 0 0 0 資料順序 • 觀察ADCMEM, send_h, send_l 三個值之間的關係(binary模式)
UART09-1.C • 大於1byte之數據傳輸(資料重組) 000X XXXX get-h 100X XXXX get-l (unsigned int)(get_h<<5) 左移5bits 0000 00XX XXX0 0000 0000 00XXXXX0 0000 + 0000 0000 000XXXXX (unsigned int)(get_l& 0x1F) 以mask取值並去除資料順序編碼 0000 00XX XXXX XXXX 100X XXXX • 觀察ADCMEM, send_h, send_l, get_h, get_l, result 值之間的關係(binary模式) & 0001 1111 000X XXXX
UART09-1.C UART_09 Tx- Rx- GND- • 大於1byte之數據傳輸 • 觀察資料發收狀況 • 程式開始時先拔除接線 先發送send_h完畢後,再接線 接著發送send_l觀察中斷程式是否有處理資料? 再繼續發送send_h及send_l,觀察中斷程式是否有處理資料?