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


Browsing this Thread:   2 Anonymous Users






Re: 關於 C30範例 [I2C slave端傳2 bytes] & [Master端收 2 bytes] 的問題
#6
版主
版主


查看用戶資訊
http://www.microchip.com.tw/modules/w ... glefile.php?cid=4&lid=229

dsPIC30F Peripheral Module Training 裡面有一I2C的教材及用 dsPIC30F4011 寫的 I2C Master & I2C Slave 的程式。

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


Re: 關於 C30範例 [I2C slave端傳2 bytes] & [Master端收 2 bytes] 的問題
#5
資深會員
資深會員


查看用戶資訊
我覺得你應該從最基本的 i2c eeprom 之類的先上手

當你能 100% 操作 i2c eeprom 時,你目前的問題就不是問題

當你要一次『coding』兩個不同的程式,你很難debug 出問題到底出在那一邊。

所以,假設你會操作 eeprom ,那你的 master 至少會送出 start / stop / reset/ address /command/ read ack/ ack / noack / read data / write data ,這時你要操作 slave 時,只要 reset -> start -> address -> command ->read data -> stop 這樣的組合就可以,程序上不會有太大的問題。

剩下的就是 slave 設定 上及程序上的問題

發表於: 2008/10/31 2:08
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於 C30範例 [I2C slave端傳2 bytes] & [Master端收 2 bytes] 的問題
#4
新會員
新會員


查看用戶資訊
我也在做两设备间I2C通讯,一起交流一下吧,我的email:
thunder.wang@emersonnetwork.com.cn

發表於: 2008/10/30 23:21
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於 C30範例 [I2C slave端傳2 bytes] & [Master端收 2 bytes] 的問題
#3
新會員
新會員


查看用戶資訊
請問一下 Master - Slave

如果 Slave 連續多筆資料發送 給Master 讀取

請問I2C機制 上還需要注意哪些.例如控制.狀態暫存器..等

發表於: 2008/10/23 11:13
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於 C30範例 [I2C slave端傳2 bytes] & [Master端收 2 bytes] 的問題
#2
新會員
新會員


查看用戶資訊
這幾天還是摸索不出來..整理如下

*Master端 操作
*Master接收端從Slave端傳送端無法連續讀取.多筆資料.

*Slaver端 送2Bytes

發表於: 2008/10/23 11:09
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


關於 C30範例 [I2C slave端傳2 bytes] & [Master端收 2 bytes] 的問題
#1
新會員
新會員


查看用戶資訊
關於 C30範例 [I2C slave端傳2 bytes] & [Master端收 2 bytes] 的問題

Dear 先進

請教一下

參考 C30_Modules 範例 欲將程式修改功能如下

1.slave 傳送 16bits ADC_value 值 to Master

2.Master 正確讀取 slave 傳來16bits slave ADC_value

3.目前程式 只可以 1bytes slave傳 與 Master讀

4.無法一次連續傳送 2bytes 的資料以上 ,
試了好幾天,還是不行,請問先進 該如何做 才能順利 連續傳送 2bytes 的資料以上 與 連續接收 2bytes 的資料以上.完整程式如附件..謝謝

*****************************************
void _ISR _SI2CInterrupt(void)
{
IFS0bits.SI2CIF = 0 ;

DummyByte = I2CRCV ;
I2CSTATbits.I2COV = 0;

if (!I2CSTATbits.D_A && I2CSTATbits.S )
// address & stop bit
{
I2CState = 0 ;
// Reset I2C State !!

if (I2CSTATbits.R_W )
// Read Command
{
if(tmp_1==0){
I2CTRN = ADC_Value;
I2CBuf[0]=I2CTRN;
tmp_1++;
}
if(tmp_1==1){
//I2CTRN = ADC_Value>>8 ;
I2CBuf[1]=I2CTRN; tmp_1++;
} if(tmp_1>=2){
tmp_1=0;
I2CCONbits.SCLREL = 1;
/* Release the clock
}

}
else // Write Command
{
I2CState = 1 ;
Nop( );
//I2CBuf[I2CIndexAddress]=I2CRCV;
}

}
else if ( I2CSTATbits.P )
//如果是 STOP , 直接將 I2CState 清除後結束
{
Nop();
I2CState = 0 ;


}//while (WaitLoop < 1000) ;

else // Write Command
{
if ( I2CState == 1 ) // Internal address byte
{
I2CState = 2 ;
I2CIndexAddress = DummyByte ;
if ( I2CIndexAddress >= 63 )
I2CIndexAddress = 63 ;
}
else if ( I2CState >= 2 )
{
I2CBuf[i++] = DummyByte ;
if (i>6)i=0;
}
else Nop();
}
}

完整程式如附件

Attach file:


Link only for registered users
Link only for registered users

發表於: 2008/10/22 16:33
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... ]

教育訓練中心

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