I2C start

hi

if someone has already used port I2C, thank you to help me,

I wants to address an eeprom (at24c32).

but its fact 15 days that I test without successes! I put pullups of 10k to 5v on scl and sda. I joint you the code, thank you

i’m using lpch 2129 with keil µVISION

///////////////////////////////////////////////////////////////////////////////////////
I2Cinit()
{ 
 PINSEL0 = 0x50;   //					
 I2CONCLR = 0x6C; // clear all flags
 I2SCLL= 80;	//100Khz 
 I2SCLH= 80;	
 I2CONSET = 0x40;    // activ I²C   				  
} 
//////////////////////////////////////////////////////////////////////////////////////////
/****************************************************************************************/
slave(char ad)
{                                    
 if(!(ad & 0x01))   //if write
{ 	
    I2CONSET = 0x20;
	while((I2STAT != 0x08) && (!(I2CONSET & 0x08))); 
	I2DAT = ad; 
	I2CONCLR = 0x28;  
	while((I2STAT != 0x18) && (!(I2CONSET & 0x08)));
	lcdprint (" address   ok");
} 
else				
{ 
    I2CONSET = 0x20;
	while((I2STAT != 0x10) && (!(I2CONSET & 0x08))); 
	I2DAT = ad; 
	I2CONCLR = 0x28;  
	while((I2STAT != 0x40) && (!(I2CONSET & 0x08)));
	home();
   	lcdprint (" adress1  ok");
}	
}  
/////////////////////////////////////////////////////////////////////////////////////////////
writeI2C(char da)
{ 
 char r;
 I2DAT= da;          
 I2CONCLR = 0x08;//clear SI 
 while(!(I2CONSET & 0x08));      
 r=I2STAT; 
 if (r != 0x28)
 {
 	  
	  lcdprint("error"); 
 } 
 mili(10);
 }
/*************************************************************
char readI2C(void)
{
    char r;
    I2CONCLR = 0x08;                   // clear SI
    while(!(I2CONSET & 0x08));        
    r=I2STAT;                        // check for error
    if (r != 0x50)
	{                 
    	lcdprint("error1");         
    }
 return I2DAT;
 }
 ////////////////////////////////////////////////////////////////////////////////////////////
StopI2C(void)
{
    I2CONSET =0x10 ;  
}       

/***************************************************************************************/
eeprom()
{
char temp;
I2Cinit(); 
slave(0xA0);
slave(0x02); // to read at adress 0200
slave(0x00);
slave(0xA1);
temp=readI2C();
StopI2C();
}

i have not looked at the code yet , although one point to note is that 10k pullup on the I2C is too high use 1k or up to 2k maximum value

ok thanks, i change pullups immediatelly

thank you too for looking code

Head over to http://www.siwawi.arubi.uni-kl.de/avr_p … xample_gnu

Get the code from the section :-

Philips LPC213x/214x examples ported for the GNU-Toolchain

I am sure there is an i2c example that should help.

Good luck.