<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > 如何通過(guò)MAX2990 I2C接口向標準EEPROM (24C04)連接

如何通過(guò)MAX2990 I2C接口向標準EEPROM (24C04)連接

作者: 時(shí)間:2010-10-25 來(lái)源:網(wǎng)絡(luò ) 收藏

  引言

本文引用地址:http://dyxdggzs.com/article/173171.htm

  本文介紹了電力線(xiàn)通信調制解調器的與外部 ,并給出了相應的固件例程。I²C總線(xiàn)受控于 (主機), 為從機器件。以下框圖給出了本文示例的硬件配置。

  

硬件配置 www.elecfans.com


  固件說(shuō)明

  I²C初始化

  一旦使能I²C模塊,SCL和SDA必須配置成漏極開(kāi)路狀態(tài),以確保I²C總線(xiàn)通信正常。由于I²C是GPIO端口的一個(gè)替代功能,固件必須確保SCL和SDA輸入在初始化期間禁止上拉(對端口控制器的輸出位寫(xiě)零實(shí)現)。

示例中,時(shí)鐘頻率為250kHz。首先需要配置的I²C

PO1_bit.Bit2 = 0; 		// Disables the GPIO function of thePO1_bit.Bit3 = 0; 		//  pinsCN_bit.I2CEN = 0; 	// Makes sure that I2C is disabled// to allow the changing of the I2C settingsI2CCN_bit.I2CMST = 1; 		// Sets the I2C engine to master modeI2CCN_bit.I2CEA = 0; 		// 7-bit address modeI2CCK_bit.I2CCKL = 0x40; 	// 2µs CLK-low, to define I2C frequencyI2CCK_bit.I2CCKH = 0x40; 	// 2µs CLK-high, to define I2C frequencyI2CTO = 200; 		// I2C_TIMEOUTI2CST = 0x400; 		// Resets I2C status registerI2CCN_bit.I2CEN = 1; 		// Enables the I2C engine

寫(xiě)模式

寫(xiě)入 時(shí),必須I²C接口寫(xiě)入以下字節:

  1. EEPROM的I²C總線(xiàn)地址(這里為0xA0)
  2. EEPROM存儲器的地址
  3. 數據字節(地址將自動(dòng)遞增)

示例中試圖寫(xiě)入以下字節,從0x00地址開(kāi)始,向EEPROM寫(xiě)入:0x12、0x34、0x56、0x78和0x90。

i2c_init_write(); 	// Sets the MAX2990 I2C Engine into write modei2c_write(0x50); 	// 24C04 write (adr = 0b1010 000 0) = 0xA0// The MAX2990 I2C engine shifts the I2C address by// 1 bit, because it will generate the R/W bit// automaticallyi2c_write(0x00); 	// word address locationi2c_write(0x12); 	// data1i2c_write(0x34); 	// data2i2c_write(0x56); 	// data3i2c_write(0x78); 	// data4i2c_write(0x90); 	// data5I2C_STOP; 		// Sends I2C stop-condition


讀模式

讀取我們寫(xiě)入EEPROM的數據時(shí),為24C04留出足夠的寫(xiě)時(shí)間非常關(guān)鍵。通常在“停止條件”后留出幾個(gè)毫秒的時(shí)間,請參考數據資料,確認您的時(shí)間設置符合IC的要求。

i2c_init_write(); 	// Sets the MAX2990 I2C engine into write modei2c_write(0x50); 	// 24C04 write (adr = 0b1010 000 0) = 0xA0// The MAX2990 I2C engine shifts the I2C address by// 1 bit, because it will generate the R/W bit// automaticallyi2c_write(0x00); 	// word address locationi2c_init_read(); 	// Sets the MAX2990 I2C engine into read modei2c_write(0x50); 	// 24C04 read (adr = 0b1010 000 1) = 0xA1// The MAX2990 I2C engine shifts the I2C address by// 1 bit, because it will generate the R/W bit// automaticallyunsigned char data[5]; 	// Array to store the received datai2c_read(data[0]); // Reads 1 byte from I2C and writes it to the arrayi2c_read(data[1]); // Reads 1 byte from I2C and writes it to the arrayi2c_read(data[2]); // Reads 1 byte from I2C and writes it to the arrayi2c_read(data[3]); // Reads 1 byte from I2C and writes it to the arrayi2c_read(data[4]); // Reads 1 byte from I2C and writes it to the arrayI2C_STOP; 		// Sends I2C stop-condition
				
            
                
			
							
上一頁(yè) 1 2 下一頁(yè)

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>