Re: [問題] 關於mController的SPI
void InitSPI(){
SPIC1_SPIE = 0; // Interrupt Disable
SPIC1_SPE = 1; // SPI enable
SPIC1_SPTIE = 0; // Transmit interrupt disable
SPIC1_MSTR = 1; // MOSI(MOMI)
SPIC1_CPOL = 0; // Clock Polarity
SPIC1_CPHA = 1; // Clock Phase
SPIC1_SSOE = 0; // SS disable
SPIC1_LSBFE = 0; // LSB First
SPIC2_MODFEN = 0;// Master Mode-Fault FUnction Enable
SPIC2_BIDIROE = 0;// Bidirectional Mode Iutput Enabled ( 0 - input, 1 -
// output)
SPIC2_SPISWAI = 0;
SPIC2_SPC0 = 1;
SPIBR_SPPR2 = 0;
SPIBR_SPPR1 = 0;
SPIBR_SPPR0 = 0;
SPIBR_SPR2 = 0;
SPIBR_SPR1 = 0;
SPIBR_SPR0 = 1;
}
char SPIRx() {
byte rec_char;
if (SPIS_SPRF) // 1st half of RDRF clear procedure
rec_char = SPID; // 2nd half of RDRF clear procedure
SPIC2_BIDIROE = 0; // enable input
while(!SPIS_SPRF){
feedCOP();
};
rec_char = SPID; // get recieved character
return SPID;
} //end SPIRx
在output的時候有Data也有CLK.
所以說SPI在Input的時候CLK也會自己跑?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 124.171.168.22
※ 編輯: comput 來自: 124.171.168.22 (09/16 20:25)
※ 編輯: comput 來自: 124.171.168.22 (09/16 20:41)
推
09/16 23:04, , 1F
09/16 23:04, 1F
沒有
→
09/16 23:06, , 2F
09/16 23:06, 2F
也沒有收到東西
※ 編輯: comput 來自: 124.171.168.22 (09/17 07:34)
推
09/18 00:25, , 3F
09/18 00:25, 3F
→
09/18 00:25, , 4F
09/18 00:25, 4F
討論串 (同標題文章)
完整討論串 (本文為第 3 之 3 篇):
ASM 近期熱門文章
PTT數位生活區 即時熱門文章