Presentation is loading. Please wait.

Presentation is loading. Please wait.

第十一章 MSP430的SPI模組.

Similar presentations


Presentation on theme: "第十一章 MSP430的SPI模組."— Presentation transcript:

1 第十一章 MSP430的SPI模組

2 USCI簡介

3 SPI 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

4 SPI-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

5 SPI in MSP430 SPI Mode

6 SPI in MSP430 Clock polarity and phase

7 SPI in MSP430

8 SPI01_MASTER.C 以示波器觀察CLK及SIMO訊號變化 CLK SIMO MSB-first

9 SPI01_MASTER.C 0x01 0x03 0x05 0x50 0x80 CLK Why?? SIMO

10 SPI01_SLAVE.C GND- 由slave接收資料
兩個人一組,一位執行SPI01_MASTER發送資料,另一位執行SPI01_SLAVE接收資料觀察UCA0RXBUF的值 SPI01_ MASTER SIMO- SOMI- CLK- GND- SPI01_ SLAVE -SIMO -SOMI -CLK -GND 上述哪一條線可拿掉而不影響結果??Why?

11 SPI02_MASTER.C 兩個人一組,一位執行SPI02_MASTER發送資料,另一位執行SPI02_SLAVE接收資料,個別觀察UCA0RXBUF的值 SPI01_ MASTER SIMO- SOMI- CLK- GND- SPI01_ SLAVE -SIMO -SOMI -CLK -GND

12 SPI02_SLAVE.C CLK SIMO SOMI Synchronous

13 SPI03_MASTER.C 中斷 兩個人一組,一位執行SPI03_MASTER發送資料,另一位執行SPI03_SLAVE接收資料,設定中斷,個別觀察UCA0RXBUF的值 SPI01_ MASTER SIMO- SOMI- CLK- GND- SPI01_ SLAVE -SIMO -SOMI -CLK -GND

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

15 SPI04_MASTER.C GND- 中斷 SPI01_ MASTER SIMO- SOMI- CLK- SPI01_ SLAVE
兩個人一組,一位執行SPI04_MASTER發送資料,另一位執行SPI04_SLAVE接收資料, SPI04_SLAVE 先執行,觀察兩端閃燈狀況。 SPI01_ MASTER SIMO- SOMI- CLK- GND- SPI01_ SLAVE -SIMO -SOMI -CLK -GND

16 SPI04_SLAVE.C 為何MASTER端總是比SLAVE端慢一次?

17 SPI05_MASTER.C GND- 讀取sensor值 SPI01_ MASTER SIMO- SOMI- CLK-
兩個人一組,一位執行SPI05_MASTER發送資料,另一位執行SPI05_SLAVE接收資料, SPI05_SLAVE 先執行,觀察MASTER端收到的值。 SPI01_ MASTER SIMO- SOMI- CLK- GND- SPI01_ SLAVE -SIMO -SOMI -CLK -GND 試想,Master端要讀Slave的值,為何需要傳資料給Slave??

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


Download ppt "第十一章 MSP430的SPI模組."

Similar presentations


Ads by Google