第十一章 MSP430 的 SPI 模組

18
微微微微微微 微微 微微 MSP430 MSP430 SPI SPI 微微 微微

description

第十一章 MSP430 的 SPI 模組. USCI 簡介. SPI. - PowerPoint PPT Presentation

Transcript of 第十一章 MSP430 的 SPI 模組

Page 1: 第十一章 MSP430 的 SPI 模組

微處理機系統

第十一章第十一章MSP430MSP430 的的 SPISPI 模組模組

Page 2: 第十一章 MSP430 的 SPI 模組

USCIUSCI 簡介簡介

Page 3: 第十一章 MSP430 的 SPI 模組

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

Page 4: 第十一章 MSP430 的 SPI 模組

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

Page 5: 第十一章 MSP430 的 SPI 模組

SPI in MSP430SPI in MSP430SPI Mode

Page 6: 第十一章 MSP430 的 SPI 模組

SPI in MSP430SPI in MSP430Clock polarity and phasehttp://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus

Page 7: 第十一章 MSP430 的 SPI 模組

SPI in MSP430SPI in MSP430

Page 8: 第十一章 MSP430 的 SPI 模組

SPISPI01_MASTER.C01_MASTER.C以示波器觀察 CLK 及 SIMO 訊號變化

MSB-first

CLK

SIMO

Page 9: 第十一章 MSP430 的 SPI 模組

CLK

SIMO

0x01

0x03

0x05

0x50

0x80Why??

SPISPI01_MASTER.C01_MASTER.C

Page 10: 第十一章 MSP430 的 SPI 模組

SPISPI01_SLAVE.C01_SLAVE.C由 slave 接收資料

兩個人一組,一位執行SPI01_MASTER 發送資料,另一位執行 SPI01_SLAVE 接收資料觀察UCA0RXBUF 的值

SPI01_MASTER

SIMO-SOMI-

CLK-

GND-

SPI01_SLAVE-SIMO-SOMI-CLK-GND

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

Page 11: 第十一章 MSP430 的 SPI 模組

SPISPI02_MASTER.C02_MASTER.C

兩個人一組,一位執行SPI02_MASTER 發送資料,另一位執行 SPI02_SLAVE 接收資料,個別個別觀察 UCA0RXBUF 的值

SPI01_MASTER

SIMO-SOMI-

CLK-

GND-

SPI01_SLAVE-SIMO-SOMI-CLK-GND

Page 12: 第十一章 MSP430 的 SPI 模組

SPISPI02_SLAVE.C02_SLAVE.C

Synchronous

請參考上圖訊號,思考 SPI 傳輸特性。 資料傳輸時,何者主動 ? 何者被動 ?

CLK

SIMO

SOMI

Page 13: 第十一章 MSP430 的 SPI 模組

SPISPI03_MASTER.C03_MASTER.C

兩個人一組,一位執行SPI03_MASTER 發送資料,另一位執行 SPI03_SLAVE 接收資料,設定中斷,個別個別觀察 UCA0RXBUF 的值

SPI01_MASTER

SIMO-SOMI-

CLK-

GND-

SPI01_SLAVE-SIMO-SOMI-CLK-GND

中斷

Page 14: 第十一章 MSP430 的 SPI 模組

SPISPI03_SLAVE.C03_SLAVE.C試拔除所有連線,觀察 MASTER端傳資料出去後是否仍會進入 RX中斷 ? 為什麼 ?

Page 15: 第十一章 MSP430 的 SPI 模組

SPISPI04_MASTER.C04_MASTER.C

兩個人一組,一位執行SPI04_MASTER 發送資料,另一位執行SPI04_SLAVE 接收資料, SPI04_SLAVE 先執行,觀察兩端閃燈狀況。

SPI01_MASTER

SIMO-SOMI-

CLK-

GND-

SPI01_SLAVE-SIMO-SOMI-CLK-GND

中斷

Page 16: 第十一章 MSP430 的 SPI 模組

SPISPI04_SLAVE.C04_SLAVE.C為何 MASTER 端總是比 SLAVE端慢一次 ?

Page 17: 第十一章 MSP430 的 SPI 模組

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??

Page 18: 第十一章 MSP430 的 SPI 模組

SPISPI05_SLAVE.C05_SLAVE.C試將紅框那一行移除,重新執行上述步驟,會有甚麼差異 ?