Using 24CXX series EEPROM with MINI-MAX/51


Built-in ReadAT24C04() and WriteAT24C04() functions in Micro C simplify access to 24CXX series EEPROM's from ATMEL, Microchip and many other manufacturers. This example writes an increasing sequence of numbers to addresses 0 to 511 on 24C04 and reads them back to verify if the values were written correctly. MINI-MAX/51 series boards have an on-board 24C04 EEPROM. This is useful for storing small amounts of non-volatile data such as calibration values, configuration values, etc.

Toolkit:Micro C 8051 Development System

Location:\bipom\devtools\MicroC\Examples\8051\medium\EEPROM\AT24C04

Code Example


	printf("\nWriting into EEPROM\n");
	
	for (ndx =0; ndx < 512; ndx++)
	{
		if(WriteAT24C04 ( 0, ndx, ndx & 0xFF ))
		{
			printf( "\nError when  writing at  address %d",ndx);
			for(;;);			
		}
		else
		{
			if(!(ndx %16)) printf("\n%04x",ndx);
			printf(" %02x",ndx & 0xFF);
		}	
	}
	
	printf("\n\nReading from  EEPROM\n");
	for (ndx =0; ndx < 512; ndx++)
	{
		if(ReadAT24C04 ( 0, ndx, &value ))
		{
			printf( "\nError when  reading from address %d",ndx);
			for(;;);			
		}
		else
		{
			if(value != (ndx & 0x00FF))
			{
				printf( "\nError in data when  reading from address %d",ndx);
				for(;;);					
			}
			else
			{
				if(!(ndx %16)) printf("\n%04x",ndx);
				printf(" %02x",value);
			}	
		}	
	}