• slider image 442
  • slider image 492
  • slider image 493
  • slider image 494
  • slider image 495
  • slider image 496
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: 求救!!!關於PIC18F4525,I2C Slave Mode問題。
#8
版主
版主


查看用戶資訊
建議你先看一下 Microchip I2C EEPROM 的規格 24LC02B 了解一下Sequential R/W and Random R/W 的命令。
http://www.microchip.com/stellent/idc ... Id=1335&dDocName=en010810

右邊再範例程式下的12.1 有Master的範例參考一下 Master 的命令 :
http://www.microchip.com.tw/example.htm

發表於: 2008/1/14 21:01
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 求救!!!關於PIC18F4525,I2C Slave Mode問題。
#7
新會員
新會員


查看用戶資訊
十二萬分的感謝您~~~可以讀寫了...

但是...I2C_Index會被清掉,Sequential Read/Write,不知該怎做??

謝謝樓上大大快速的回覆!!!

再次拜託了!!

發表於: 2008/1/14 17:23
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 求救!!!關於PIC18F4525,I2C Slave Mode問題。
#6
版主
版主


查看用戶資訊
現在的作法是 : PIC18F & 16-bit 系列的範例幾乎都是使用 C 來寫。PIC16F 系列因為 Microchip 並沒有出自己的 C compiler 所以會以 assembly 為主。

發表於: 2008/1/11 16:17
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 求救!!!關於PIC18F4525,I2C Slave Mode問題。
#5
高級會員
高級會員


查看用戶資訊
是C的範例,真不錯!
感覺MICROCHIP從以前的PURE ASSEMBLY慢慢的也發布C語言的範例了!我本身是以C/C++為開發語言,常常因為FAE說他都用組語寫的,而碰壁,最後反而都自己加班多花時間解決的,希望MICROCHIP專門有一些C的工程師來面對我們這些C的用戶!!個人淺見!!

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


Re: 求救!!!關於PIC18F4525,I2C Slave Mode問題。
#4
版主
版主


查看用戶資訊
Calvin 已經將 I2C Master & Slave 的範例放上去了。
http://www.microchip.com.tw/modules/wfdownloads/viewcat.php?cid=12

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


Re: 求救!!!關於PIC18F4525,I2C Slave Mode問題。
#3
版主
版主


查看用戶資訊
待會會請 Calvin 將他寫的 I2C Master & Slave 的範例放在下載中心裡的範例程式哩,此範例使用 APP001及PIC18F4520

發表於: 2008/1/11 14:02
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 求救!!!關於PIC18F4525,I2C Slave Mode問題。
#2
高級會員
高級會員


查看用戶資訊
void write_i2c(unsigned char data)這函數裡,在while(SSPSTATbits.BF){} 之前,先對SSPBUF做讀取看看,因為有可能SSPBUF已經被SLAVE ADDRESS佔住了,所以你是無法將你要回給MASTER的DATA寫進去!

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


求救!!!關於PIC18F4525,I2C Slave Mode問題。
#1
新會員
新會員


查看用戶資訊
原先參考 AN743,但一直有Read 錯誤,後來於Microchip 英文討論版看到,AN743有些問題,但是還是無解,不知有哪位大大能幫幫我解決~~~

請參考以下中斷程式:

unsigned char temp = SSPSTAT & 0b00101101; // Mask out unimportant bits in SSPSTAT
switch (temp) {
// State 1: Write operation, last byte was an address, buffer is full.
case ( 0b00001001 ):
// clear receive buffer
index = 0; // Clear the buffer index
read_i2c(); // Do a dummy read of SSPBUF
break;
// State 2: Write operation, last byte was data, buffer is full.
case ( 0b00101001 ):
receivedBuffer[index++] = read_i2c();
if(index==64) index = 0;
break;
// State 3: Read operation, last byte was an address, buffer is full.
case ( 0b00001101 ):
write_i2c(writeData);
break;
// State 4: Read operation, last byte was data, buffer is empty.
case ( 0b00101100 ):
write_i2c(writeData);
break;
default:
break;
}
}
}
void write_i2c(unsigned char data){
while(SSPSTATbits.BF){} // Wait until buffer is empty
do{
SSPCONbits.WCOL = 0; // Clear WCOL flag
SSPBUF = data; // Write the data to the buffer
} while ( SSPCONbits.WCOL ); // Loop when there's a write collision
SSPCONbits.CKP = 1 // Release the clock
}
unsigned char read_i2c(){
return SSPBUF;
}


State 4有時進不去...Master可以讀取第一筆(Byte),但第二筆(Byte)就再也無回應了...

以上拜託了!!謝謝!!

發表於: 2008/1/11 13:24
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... ]

教育訓練中心

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