標(biāo)題: 關(guān)于24c02系列IIC總線的研究 [打印本頁]

作者: dagu    時間: 2014-12-23 01:43
標(biāo)題: 關(guān)于24c02系列IIC總線的研究
    明確這樣幾條,就能正確理解IIC總線的原理:

1.      scl信號永遠是由主機產(chǎn)生的。

2.      主機和從機都能作為發(fā)送端,也都能作為接收端

3.      主機在寫數(shù)據(jù)的時候主機是發(fā)送端,從機是接收端,主機在讀數(shù)據(jù)的時候從機是發(fā)送端,主機是接收端。

4.      在頁寫數(shù)據(jù)的時候會以8或16作為頁寫數(shù)據(jù)的個數(shù),如果寫入的數(shù)據(jù)超過這個數(shù)值那么先前寫入的數(shù)據(jù)會被覆蓋掉。

5.      在連續(xù)讀的模式下數(shù)據(jù)的地址會一直增加下去,沒有頁讀的8或16的限制。

6.      在SCL在高電平的時候DAT是不能變化的,否則這個變化會作為開始或結(jié)束的信號。根據(jù)這一條就可以斷定,DAT數(shù)據(jù)的變化是在SCL為低電平的時候,也就能說明在向24C02寫數(shù)據(jù)的時候?qū)懲?個數(shù)據(jù)之后的 那個下降沿會觸發(fā)第9個應(yīng)答位。這個應(yīng)答位必須在SCL變?yōu)楦唠娖街熬头(wěn)定下來,否則會被視為起始位或是結(jié)束位。同位的道理在讀數(shù)據(jù)的時候,當(dāng)24C02發(fā)完一個8位的數(shù)據(jù)之后,在之后的那個SCL的下降沿,單片機必須先將DAT變?yōu)楦唠娙缓蟛拍軐CL拉為高電平,否則也會出現(xiàn)上面的問題也就是會被24C02視為起始位或是結(jié)束位。

7.      24C02芯片有一個TWR參數(shù),就是兩次寫操作的最小時間間隔,這個時間因不同的芯片生產(chǎn)廠商有不同,一般兩次寫的時間間隔設(shè)定為10ms是足夠的。

8.      關(guān)于24C02的頁寫入模式,我察看了一個24C02的數(shù)據(jù)手冊對頁寫模式的摘寫下來:Page Write. For the Page Writemode, the MODEpin must be at VIL. The Page Write mode allows upto 8 bytes to bewritten in a single  write cycle,providedthat they are all located in the same ’row’in the memory: that is the 5 mostsignificant mem-ory address bits (A7-A3) are the same. The mastersends from oneup to 8 bytes of data, which areeach acknowledged by the memory. After eachbyteis transfered, the internal byte address counter(3 least significant bits only)is incremented. Thetransfer is terminated by the master generating aSTOPcondition. Care must be taken to avoid ad-dress counter ’roll-over’ which couldresult in databeing overwritten. Note that, for any write mode,the generationby the master of the STOP conditionstarts the internal memory program cycle.All inputsare disabled until the completion of this cycle andthe memory willnot respond to any request.

這里說明頁寫模式下最多只能寫入8個字節(jié),如果寫得超過8個字節(jié),前面的數(shù)據(jù)就會被覆蓋掉,這里就要注意寫入24C02的基地址了,只能是8的整數(shù)倍了,而且也只能最多寫入8個數(shù)據(jù),這個在編寫頁寫函數(shù)時要特注意。

當(dāng)然對于不是24C02的芯片,比如24C04,或是容量更大的芯片,這個數(shù)據(jù)就不是8個了,有可能是16個,或是32個。

9.      關(guān)于24C02的順序讀的操作,是沒有頁的概念的,下面是摘于24C02的數(shù)據(jù)手冊:

Sequential Read. This mode can be initiated witheither a Current Address Read or a Random Ad-dress Read. However, in this case the masterDOES acknowledge the data byte output and thememory continues to output the next byte in se-quence. To terminate the stream of bytes, themaster must NOT acknowledge the last byte out-put, but MUST generate a STOP condition. Theoutput data is from consecutive byte addresses,with the internal byte address counter automat-ically incremented after each byte output. After acount of the last memory address, the addresscounter will ’roll- over’ and the memory will continueto output data.

10.  應(yīng)答是在SCL在低電平的時候?qū)AT拉為低電平,非應(yīng)答是在SCL在低電平的時候?qū)AT拉為高電平,這是沒有任何問題的,只是要區(qū)分,應(yīng)答是主機發(fā)出的還是從機發(fā)出的,因為應(yīng)答的一定是接收方,主機和從機都可能是接收方,但是這里注意非應(yīng)答數(shù)據(jù)一定是主機發(fā)出的,從這一點可以看出主機和從機在邏輯上是不對稱的。






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1