当前位置:网站首页>20、 EEPROM memory (AT24C02) (similar to AD)

20、 EEPROM memory (AT24C02) (similar to AD)

2022-07-06 03:51:00 Can't go on the ground

 EEPROM Memory (AT24C02): Power down data is also saved

//************EEPROM Memory ***********************************************
unsigned char eeprom_read(unsigned char add)// from EEPROM( Which address ) Reading data 
{
	unsigned char temp;
	
	IIC_Start();
	IIC_SendByte(0xa0);// Allow writing ( read 1/ Write 0)  1010 000 0/1
	IIC_WaitAck();
	IIC_SendByte(add);// Tell it the address 
	IIC_WaitAck();
	IIC_Stop();
	
	IIC_Start();
	IIC_SendByte(0xa1);// Allow to read ( read 1/ Write 0)  1010 000 0/1
	IIC_WaitAck();
	temp = IIC_RecByte();// Reading data 
	IIC_Stop();
	
	return temp;
	Delayms(5);//( Read continuously , Write in succession , Only the first one is right ) Need a delay 
}

void eeprom_write(unsigned char add, dat)// Go to EEPROM Writing data ( Where is the writing , What to write )
{
	IIC_Start();
	IIC_SendByte(0xa0);// Allow writing ( read 1/ Write 0)  1010 000 0/1
	IIC_WaitAck();
	IIC_SendByte(add);// Tell it the address 
	IIC_WaitAck();
	IIC_SendByte(dat);// Write content 
	IIC_WaitAck();
	IIC_Stop();
	Delayms(5);// Need a delay 
}
//***********************************************************************

application :

    EEPROM_write(0x01,32);// towards 0x01  Write 32
	dat1 = EEPROM_read(0x01);// read 0x01  The data of (dat1 It's a digital tube )

原网站

版权声明
本文为[Can't go on the ground]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202132302401486.html