• slider image 442
  • slider image 497
  • slider image 498
  • slider image 499
  • slider image 500
  • slider image 502
:::


Browsing this Thread:   1 Anonymous Users






訪客
Re: 請問.......下載範例F4520_S.c是否少一行設定.....
#3
SSPCON2bits.SEN = 1 ; 是在主程式裡送出 Start condition 訊號用的,Slave 端無須使用????

感謝版主回覆,有些疑問想再進一步釐清.....

### PIC當I2C之Slave ###
SSPCON2bits.SEN是否需設定????

依據PIC18F452 data sheet<DS39564B-page137>

REGISTER 15-5: SSPCON2: MSSP CONTROL REGISTER 2 (I2C MODE)

bit 0 SEN: START Condition Enabled/Stretch Enabled bit
In Master mode:
1 = Initiate START condition on SDA and SCL pins. Automatically cleared by hardware.
0 = START condition IDLE
@@@@ In Slave mode: @@@@@@
1 = Clock stretching is enabled for both Slave Transmit and Slave Receive (stretch enabled)
0 = Clock stretching is enabled for slave transmit only (Legacy mode)

==>PIC當I2C之Slave,SSPCON2bits.SEN無設定(=0),Slave Receive則無Clock stretching
==>Master 連續送資料.......Slave overflow......

錯誤之處,再請版主修正
謝謝!!!!


Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問.......下載範例F4520_S.c是否少一行設定.....
#2
版主
版主


查看用戶資訊
SSPCON2bits.SEN = 1 ; 是在主程式裡送出 Start condition 訊號用的,Slave 端無須使用。I2C Master 是呼叫 EEPROM 的函數送出 I2C 的訊號的,其中 EEPROM 的函數是由Microchip 所提供的周邊函數庫。

CKP 在 Slave 是用來 Enable SCL for handshake control, Master 傳送讀取資料命令後並在Slave 傳完 ACK 後 CKP 位元自動設為零,需將要傳給 Master 的資料寫入 SSPBUF 後將 CKP 設為 1 後 Master 就可以傳 Clock 將資料讀走。

如果 Master 只是傳資料給 Slave 而已,則 CKP 不會有限制 SCL 的功能,這時要注意 overflow 的問題發生。

可以參考 I2C Slave mode waveforms for reception (7-bit address) & transmission waveforms 這兩張圖對 CKP 的說明是不一樣的。

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


訪客
請問.......下載範例F4520_S.c是否少一行設定.....
#1
使用PIC18F452當 I2C slave,送資料給master沒問題,
(参考本網站下載範例 F4520_S.c)
但..收資料,一進入中斷,尚未做任何處理,SSPOV即為1,
why????

此時,slave尚未送ACK,master應該不會傳送
第二筆資料?????(示波器量測發現,資料有送出....)



==>F4520_S.c是否少一行設定 SSPCON2bits.SEN = 1 ;
才會出現上述現象,因為收資料時SSPCON1bits.CKP 無動作...........master資料一直送出

若以上敘述有錯,請各位修正......謝謝!!!!



< F4520_S.c>
//************************************************
//* Initial I2C Master Mode with 7 bits Address *
//* Clock Speed : 100KHz @16MHz *
//************************************************
void Initialize_I2C_Slave(void)
{
TRISCbits.TRISC3=1;
TRISCbits.TRISC4=1;
OpenI2C(SLAVE_7,SLEW_ON);
SSPADD= EEPROM_ADDR;
SSPSTATbits.CKE=1; // SMBus specific inputs
PIR1bits.SSPIF = 0 ;
PIE1bits.SSPIE = 1 ;
RCONbits.IPEN = 0 ;
SSPCON1bits.CKP = 1 ;
}

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... ]

教育訓練中心

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