![]() |
發(fā)布時間: 2018-3-24 19:18
正文摘要:1、I2c啟動 由上圖可以看書寫數(shù)據(jù)的步驟為:1)啟動I2c; 2)寫入設(shè)備地址; 3)寫入要讀取數(shù)據(jù)存放的地址; 4)啟動I2c; 5)寫入設(shè)備地址(第八位為1,表示讀數(shù)據(jù)); 6)讀數(shù)據(jù); 7)給設(shè)備發(fā) ... |
//·¢Ëíack void I2c_sendAck(bit ack) { SDA = ack; SCL = 1; delay(1); SCL = 0; //»ñè¡ack bit I2c_getAck(void) { bit ack; SDA = 1; SCL = 1; 什么意思?! |
試了整天,Protues 里的I2C Debugger 都是收到A0 FF FF 看了其他文章才知道,等ACK時要先把SDA 置0 bit I2c_getAck(void) { bit ack; SDA = 0;//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< SCL = 1; delay(1); ack = SDA; SCL = 0; return ack; } |
應用代碼中void I2c_start()和void I2c_stop(),程序變的可運行,好評 |
剛好用到,謝謝樓主分享。 |
挺好的啊![]() |
不錯,支持樓主,支持51hei |
有匯編代碼嗎? |
Powered by 單片機教程網(wǎng)