• 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: spi介面的問題
#10
版主
版主


查看用戶資訊
Software SPI 腳位的定義在 sw-spi.h 的檔案哩,你可以參考 C18 Libraries User's Guide 的第 3.5 章的說明。

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


Re: spi介面的問題
#9
高級會員
高級會員


查看用戶資訊
還有幾個問題想問一下、
我用的是18f8622
我的sw_spi內的腳位需要修改嗎?
因為跟內部所設定的腳位不同


發表於: 2007/11/29 10:31
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: spi介面的問題
#8
資深會員
資深會員


查看用戶資訊
Eigen 說的沒錯 如果 SSPCON 沒設對 SPI module 怎麼也不會動. 我一開始設錯 就卡在 bf 那邊. 後來改正後就pass 了
我把 SCK input/output 設錯 照跑無誤

會不會你的 C compiler 沒支援 6422 或你的 p18c6422.h 有問題

要不你用個 inline assembly 去設 SSPCON 的值 注意 Register Page 要選對

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


Re: spi介面的問題
#7
資深會員
資深會員


查看用戶資訊
C:\mcc18\doc\MPLAB-C18-Libraries_51297f.pdf

2.8 節 不是有很容易的說明和範例?

發表於: 2007/11/28 12:50
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: spi介面的問題
#6
版主
版主


查看用戶資訊
參照:
PIE1:PSPIF = 0(請問一下這個是設什麼用的)

PSP 是 Paralle Slave Port 的縮寫,PSP 2k7 Data Bus 是設計在 PORTD , 控制信號在 PORTE。主要是用來被高速的Host透過並列的方式讀取資料。

PIE1:PSPIF = 0 是清除 PSP 的中斷旗號。

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


Re: spi介面的問題
#5
高級會員
高級會員


查看用戶資訊
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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: spi介面的問題
#4
高級會員
高級會員


查看用戶資訊
以下是我有關的設定
我用的是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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: spi介面的問題
#3
資深會員
資深會員


查看用戶資訊
spi 初始化失敗

導致後續的 讀寫無法 進行

在初始化失敗的情況下,你 writespi1

spi 模組是不會產生 clock 將資料送出,自然也不會有接收的動作

所以 ssp1stabit.BF bit 永遠為0

發表於: 2007/11/28 8:53
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: spi介面的問題
#2
資深會員
資深會員


查看用戶資訊
用 SSPIF 來判斷會不會好些

另外有 collision 偵測到後 要 clear WCOL...

SSPCON 你如何設定

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


spi介面的問題
#1
高級會員
高級會員


查看用戶資訊
#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
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... ]

教育訓練中心

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