• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: 如何讓兩個CPU使用SPI通訊(master & slave)?
#4
資深會員
資深會員


查看用戶資訊
對於 SPI 的簡介可參考Wiki

裡面提到 CPOL,CPHA 對應 CKP, Not CKE
CKE := Not CPHA

CKE = 1 指資料在第一個 edge 有效
CKE = 0 指資料在第二個 edge 有效

所以
當 CKE=1 時需設 SS enabled, -> SSPM<3:0>=0100
也就是說 SS 接腳必須用 (not optional), 詳見後述

當 CKE=0 時 SS 可用可不用 SS 接腳可做其他用途 (optional)

若是用 Synchronous Slave mode 則必須設 SS enabled, -> SSPM<3:0>=0100 不管 CKE 值為何

若 SS enabled, 當 SS pin 為 high 時 SPI 的 shift counter 會歸零 所以萬一資料傳到一半 SS pin 忽然變為 high 再變為 low 則資料從 bit7 開始傳起
---------------
SSPM<3:0>=0100 使用 SS pin (Slave mode)

SSPM<3:0>=0101 不使用 SS pin (Slave mode)
---------------
簡單來講 SPI 的傳輸 全靠 SCK 來控制 一有 clock 就開試運作
若 CKE=1, 因 slave 並不知道何時將資料 放到 SDO 接腳 若在第一個 edge, Master 就讀資料就有問題 所以須靠 SS (slave select) 來幫助 當 slave 的 SS 變為 low 時, slave 就知道要開始傳輸資料了 在 SDO 就會先放 bit7, 所以當第一個 clock 的第一個edge時 SDO 已有資料準備好

若 CKE=0, 因 clock 一有變化(第一個edge) slave 就知傳輸要開始 於是就把資料 bit7 送到 SDO 在第二個 edge 時就已 ready, 因此並不需用到 SS pin

發表於: 2007/11/23 15:43
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 如何讓兩個CPU使用SPI通訊(master & slave)?
#3
資深會員
資深會員


查看用戶資訊
大家好:
(1).因由18f4423之DataSheet中看到圖17-5&17-6,
當CKE=0則/SS為Option而CKE=1則/SS為Not Option,
不知是什麼意思?
(2).於17.3.7 SLAVE SELECT SYNCHRONIZATION
Note 1: When the SPI is in Slave mode with SS pin
control enabled (SSPCON1<3:0> = 0100),
the SPI module will reset if the SS pin is set
to VDD.
2: If the SPI is used in Slave mode with CKE
set, then the SS pin control must be enabled.
(3).SSPM0~SSPM3:若設為0100及0101則與上面兩點
又有什麼關係呢?

煩請指教,Thanks.

發表於: 2007/11/21 14:38
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 如何讓兩個CPU使用SPI通訊(master & slave)?
#2
版主
版主


查看用戶資訊
CKE & CKP 是用來設定 SPI 的 Mode 共有四種 Mode 00, 01 ,10, 11。Master 及 Slave 兩邊都要設成一樣的 Mode 後才可以溝通。所謂 Mode 就是 SCK 是在上升緣或下降緣時擷取資料。

/SS pin 在 Slave 時有效,顧名思義 SS 就是 Slave Select 的功能,把她想成 /CS (Chip Select) 的功能就好了。一般在 Master 端是以一個 I/O 腳的輸出來控制 Slave 的 SS 腳,用來 Enable SPI Slave 的。

發表於: 2007/11/21 14:03
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


如何讓兩個CPU使用SPI通訊(master & slave)?
#1
資深會員
資深會員


查看用戶資訊
大家好:
個人剛接觸SPI,最主要問題是slave那邊的設定問題?
1.不知/SS及CKE的關係?
2.若不用/SS是否可行?
請指教,Thanks.

發表於: 2007/11/21 13:51
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------