• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   2 Anonymous Users






Re: dsPIC30F2010 I2C 使用問題
#8
版主
版主


查看用戶資訊
其實看程式真的不一定看的出來 Bug 在哪哩,一般只有猜想是有可能bug是出在哪裡而已。

所以,猜了猜,有可能你忘了在做完 I2C 接收後需重新設定 SCLREL =1 讓 Slave 重新放開 SCL。 這樣 Master 才可以控制 SCL 送出 Clock 來。

請參考一下 dsPIC30F Family Reference Manual 裡,第21章 I2C Figure 21-29 Slave Message 的 Timming 的說明。

發表於: 2008/4/11 15:25
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: dsPIC30F2010 I2C 使用問題
#7
新會員
新會員


查看用戶資訊
不好意思....
我還是找不出問題!!
附上程式, 是否程式程序出問題....


I2C Slave中斷副程式...

void _attribute_((__interrupt__)) _SI2CInterrupt(void){unsigned char Called_ADR;
unsigned char I2CS_RxBuf;

if(I2CSTATbits.D_A){
I2CS_RxBuf = SlaveReadI2C();
I2CCONbits.SCLREL=1;
}
else{
Called_ADR = SlaveReadI2C();
if(I2CSTATbits.R_W){
SlaveWriteI2C(0xAA);
}
}
IFS0bits.SI2CIF = 0;
}

I2C Master 程式............

void I2C_Master_Receiver(unsigned char I2CS_ADR, unsigned char I2CM_RxBuf){
I2C_Start_Bit();
I2C_MWR_Byte(I2CS_ADR+1);
I2CM_RxBuf = MasterReadI2C();
NotAckI2C();
I2C_Stop_Bit();
return;
}

發表於: 2008/4/10 17:41
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: dsPIC30F2010 I2C 使用問題
#6
版主
版主


查看用戶資訊
參考一下 "dsPIC30F Module Training - I2C 教材及練習 " 裡的 code Example for I2C Slive :
http://www.microchip.com.tw/modules/mydownloads/viewcat.php?cid=4

發表於: 2008/4/9 15:10
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: dsPIC30F2010 I2C 使用問題
#5
新會員
新會員


查看用戶資訊
Slave在接收完訊號時, 馬上使用C30資料庫裡的副程式
SlaveWriteI2C(0xAA);

其內容是....
void SlaveWriteI2C(unsigned char data_out)
{
/* data transferred to I2CTRN reg */
I2CTRN = data_out;
/* Release the clock */
I2CCONbits.SCLREL = 1;
}

而且, 我也確定I2CCONbits.SCLREL有等於1....
不過還是一樣沒有訊號

發表於: 2008/4/9 13:46
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: dsPIC30F2010 I2C 使用問題
#4
版主
版主


查看用戶資訊
那這樣就有問題了,Slave 端處理完接收資料離開中斷前是否有將 SCL 放開,因為 SCL 在 I2C 裡是可以用來做 Handshake 的,Slave hold 住 SCL 的話 Master 是不會送出任何訊號出來的。

發表於: 2008/4/3 17:20
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: dsPIC30F2010 I2C 使用問題
#3
新會員
新會員


查看用戶資訊
這時候 SCL & SDA都在Low livel.....

OK ! 我會先是一下Master是否正常讀寫!!

謝謝....

發表於: 2008/4/3 17:04
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: dsPIC30F2010 I2C 使用問題
#2
版主
版主


查看用戶資訊
請問這時候 SCL 是否在 Hi level ?
一般在使用 I2C 時,以 Slave 端比較複雜也比較不好寫。
建議以先用一個 24LC04 EEPROM 先當一下 I2C Slave,先確定 Master 的程式能正確讀、寫 EEPROM 的內容無誤後,再來測試 Slave 的程式。這樣比較好釐清是誰的錯誤。

有關I2C的範例可以參考底下的教材與練習: dsPIC30F Module Training - I2C 教材及練習
http://www.microchip.com.tw/modules/mydownloads/viewcat.php?cid=4

發表於: 2008/4/3 15:32
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


dsPIC30F2010 I2C 使用問題
#1
新會員
新會員


查看用戶資訊
手上有2顆dsPIC30F2010,
1顆做I2C Master 使用, 1顆做Slave使用.

做 Master 寫資料到 Slave 的動作 OK!
但 Master 要讀 Slave 資料時, 就無法執行!

目前只做傳送1Byte資料,
I2CCONbits.ACKEN=1,
Master/Slave動作如下:

Master 送位址及R/W_bit=1, 等待確認...
Slave 接收後, 讀出位址並送Ack_bit !!
Master 確認Ack_bit後, I2CCONbits.RCEN=1, 等待接收...
Slave 將資料載入I2CTRN, I2CCONbits.SCLREL=1, 釋放 SCL_Line!!

此時, 問題發生了!!!!!!!!!!!!
示波器放完全沒有Master送出的Clock....
Slave也無法送出Data......

請問, 我還有什麼沒有設定到的???
謝謝!!!!

發表於: 2008/4/2 14:42
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... ]

教育訓練中心

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