Download - 第十一章 MSP430 的 SPI 模組
微處理機系統
第十一章第十一章MSP430MSP430 的的 SPISPI 模組模組
USCIUSCI 簡介簡介
SPISPI The Serial Peripheral Interface Bus or SPI (pronounced as either ess-pee-
eye or spy) bus is a synchronous serial data link standard, named by Motorola, that operates in full duplex mode. Devices communicate in master/slave mode where the master device initiates the data frame. Multiple slave devices are allowed with individual slave select (chip select) lines. Sometimes SPI is called a four-wire serial bus, contrasting with three-, two-, and one-wire serial buses. SPI is often referred to as SSI (Synchronous Serial Interface).
-from Wiki http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
SPI-InterfaceSPI-Interface The SPI bus specifies four logic signals:
SCLK: serial clock (output from master); MOSI: master output, slave input (output from master); MISO: master input, slave output (output from slave); SS: slave select (active low, output from master).
The SDI/SDO (DI/DO, SI/SO) convention requires that SDO on the master be connected to SDI on the slave, and vice-versa. Chip select polarity is rarely active high, although some notations (such as SS or CS instead of nSS or nCS) suggest otherwise.
-from Wiki http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
SPI in MSP430SPI in MSP430SPI Mode
SPI in MSP430SPI in MSP430Clock polarity and phasehttp://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
SPI in MSP430SPI in MSP430
SPISPI01_MASTER.C01_MASTER.C以示波器觀察 CLK 及 SIMO 訊號變化
MSB-first
CLK
SIMO
CLK
SIMO
0x01
0x03
0x05
0x50
0x80Why??
SPISPI01_MASTER.C01_MASTER.C
SPISPI01_SLAVE.C01_SLAVE.C由 slave 接收資料
兩個人一組,一位執行SPI01_MASTER 發送資料,另一位執行 SPI01_SLAVE 接收資料觀察UCA0RXBUF 的值
SPI01_MASTER
SIMO-SOMI-
CLK-
GND-
SPI01_SLAVE-SIMO-SOMI-CLK-GND
上述哪一條線可拿掉而不影響結果 ??Why?
SPISPI02_MASTER.C02_MASTER.C
兩個人一組,一位執行SPI02_MASTER 發送資料,另一位執行 SPI02_SLAVE 接收資料,個別個別觀察 UCA0RXBUF 的值
SPI01_MASTER
SIMO-SOMI-
CLK-
GND-
SPI01_SLAVE-SIMO-SOMI-CLK-GND
SPISPI02_SLAVE.C02_SLAVE.C
Synchronous
請參考上圖訊號,思考 SPI 傳輸特性。 資料傳輸時,何者主動 ? 何者被動 ?
CLK
SIMO
SOMI
SPISPI03_MASTER.C03_MASTER.C
兩個人一組,一位執行SPI03_MASTER 發送資料,另一位執行 SPI03_SLAVE 接收資料,設定中斷,個別個別觀察 UCA0RXBUF 的值
SPI01_MASTER
SIMO-SOMI-
CLK-
GND-
SPI01_SLAVE-SIMO-SOMI-CLK-GND
中斷
SPISPI03_SLAVE.C03_SLAVE.C試拔除所有連線,觀察 MASTER端傳資料出去後是否仍會進入 RX中斷 ? 為什麼 ?
SPISPI04_MASTER.C04_MASTER.C
兩個人一組,一位執行SPI04_MASTER 發送資料,另一位執行SPI04_SLAVE 接收資料, SPI04_SLAVE 先執行,觀察兩端閃燈狀況。
SPI01_MASTER
SIMO-SOMI-
CLK-
GND-
SPI01_SLAVE-SIMO-SOMI-CLK-GND
中斷
SPISPI04_SLAVE.C04_SLAVE.C為何 MASTER 端總是比 SLAVE端慢一次 ?
SPISPI05_MASTER.C05_MASTER.C兩個人一組,一位執行SPI05_MASTER 發送資料,另一位執行SPI05_SLAVE 接收資料, SPI05_SLAVE 先執行,觀察 MASTER端收到的值。
SPI01_MASTER
SIMO-SOMI-
CLK-
GND-
SPI01_SLAVE-SIMO-SOMI-CLK-GND
讀取 sensor 值
試想, Master 端要讀 Slave 的值,為何需要傳資料給 Slave??
SPISPI05_SLAVE.C05_SLAVE.C試將紅框那一行移除,重新執行上述步驟,會有甚麼差異 ?