Re: spi介面的問題
|
||||
---|---|---|---|---|
版主
|
Software SPI 腳位的定義在 sw-spi.h 的檔案哩,你可以參考 C18 Libraries User's Guide 的第 3.5 章的說明。
發表於: 2007/11/29 11:27
|
|||
|
Re: spi介面的問題
|
||||
---|---|---|---|---|
高級會員
|
還有幾個問題想問一下、
我用的是18f8622 我的sw_spi內的腳位需要修改嗎? 因為跟內部所設定的腳位不同
發表於: 2007/11/29 10:31
|
|||
|
Re: spi介面的問題
|
||||
---|---|---|---|---|
資深會員
|
C:\mcc18\doc\MPLAB-C18-Libraries_51297f.pdf
2.8 節 不是有很容易的說明和範例?
發表於: 2007/11/28 12:50
|
|||
|
Re: spi介面的問題
|
||||
---|---|---|---|---|
版主
|
參照:
PIE1:PSPIF = 0(請問一下這個是設什麼用的) PSP 是 Paralle Slave Port 的縮寫,PSP 2k7 Data Bus 是設計在 PORTD , 控制信號在 PORTE。主要是用來被高速的Host透過並列的方式讀取資料。 PIE1:PSPIF = 0 是清除 PSP 的中斷旗號。
發表於: 2007/11/28 11:21
|
|||
|
Re: spi介面的問題
|
||||
---|---|---|---|---|
高級會員
|
Re: spi介面的問題
以下是我有關的設定 我用的是18f8622 下面是sw_spi的修改資料。 #define SW_CS_PIN PORTJbits.RJ4 // Chip Select #define TRIS_SW_CS_PIN TRISJbits.TRISJ4 #define SW_DIN_PIN PORTCbits.RC4 // Data in #define TRIS_SW_DIN_PIN TRISCbits.TRISC4 #define SW_DOUT_PIN PORTCbits.RC5 // Data out #define TRIS_SW_DOUT_PIN TRISCbits.TRISC5 #define SW_SCK_PIN PORTCbits.RC3 // Clock #define TRIS_SW_SCK_PIN TRISCbits.TRISC3 SSP1STAT = 0x40; SSP1CON1 = 0x22; INTCON2:INTEDG3 = 1 INTCON2:INTEDG2 = 0 INTCON2:INTEDG1 = 0 INTCON2:INTEDG0 = 0 PIE1:PSPIF = 0(請問一下這個是設什麼用的) PIE1:SSP1IF = 0
發表於: 2007/11/28 10:57
|
|||
|
Re: spi介面的問題
|
||||
---|---|---|---|---|
高級會員
|
以下是我有關的設定
我用的是18f8622 下面是sw_spi的修改資料。 #define SW_CS_PIN PORTJbits.RJ4 // Chip Select #define TRIS_SW_CS_PIN TRISJbits.TRISJ4 #define SW_DIN_PIN PORTCbits.RC4 // Data in #define TRIS_SW_DIN_PIN TRISCbits.TRISC4 #define SW_DOUT_PIN PORTCbits.RC5 // Data out #define TRIS_SW_DOUT_PIN TRISCbits.TRISC5 #define SW_SCK_PIN PORTCbits.RC3 // Clock #define TRIS_SW_SCK_PIN TRISCbits.TRISC3 SSP1STAT = 0x40; SSP1CON1 = 0x22; INTCON2:INTEDG3 = 1 INTCON2:INTEDG2 = 0 INTCON2:INTEDG1 = 0 INTCON2:INTEDG0 = 0 PIE1:PSPIF = 0(請問一下這個是設什麼用的) PIE1:SSP1IF = 0
發表於: 2007/11/28 10:04
|
|||
|
Re: spi介面的問題
|
||||
---|---|---|---|---|
資深會員
|
spi 初始化失敗
導致後續的 讀寫無法 進行 在初始化失敗的情況下,你 writespi1 spi 模組是不會產生 clock 將資料送出,自然也不會有接收的動作 所以 ssp1stabit.BF bit 永遠為0
發表於: 2007/11/28 8:53
|
|||
|
Re: spi介面的問題
|
||||
---|---|---|---|---|
資深會員
|
用 SSPIF 來判斷會不會好些
另外有 collision 偵測到後 要 clear WCOL... SSPCON 你如何設定
發表於: 2007/11/27 18:43
|
|||
|
spi介面的問題
|
||||
---|---|---|---|---|
高級會員
|
#include <p18cxxx.h>
#include <spi.h> /******************************************************************** * Function Name: WriteSPI1 * * Return Value: Status byte for WCOL detection. * * Parameters: Single data byte for SPI1 bus. * * Description: This routine writes a single byte to the * * SPI1 bus. * ********************************************************************/ unsigned char WriteSPI1( unsigned char data_out ) { SSP1BUF = data_out; // write byte to SSP1BUF register if ( SSP1CON1 & 0x80 ) // test if write collision occurred return ( -1 ); // if WCOL bit is set return negative # else { while( !SSP1STATbits.BF ); // wait until bus cycle complete } return ( 0 ); // if WCOL bit is not set return non-negative# } 我在用了內部的函數結果一直停在 while( !SSP1STATbits.BF ); 這是什麼原因呢?
發表於: 2007/11/27 17:52
|
|||
|