This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem with i2c

hai,
I have few problems in working lpc2468 with i2c
1) How can I send data to EEPROM?(in arm core some status codes are available weather they have to give by our self or it will be generated automatically) 2)What this function I2C0MasterHandler() doing and when it will be called

i have included the int handler function here
Please clarify my doubts earlier

void I2C0MasterHandler(void) __irq
{ BYTE StatValue;

/* this handler deals with master read and master write only */ StatValue = I20STAT; IENABLE; /* handles nested interrupt */ switch ( StatValue ) { case 0x08: /* A Start condition is issued. */ I20DAT = I2CMasterBuffer[0]; I20CONCLR = (I2CONCLR_SIC | I2CONCLR_STAC); I2CMasterState = I2C_STARTED; break;

case 0x10: /* A repeated started is issued */ if ( I2CCmd == LM75_TEMP ) { I20DAT = I2CMasterBuffer[2]; } I20CONCLR = (I2CONCLR_SIC | I2CONCLR_STAC); I2CMasterState = I2C_RESTARTED; break;

case 0x18: /* Regardless, it's a ACK */ if ( I2CMasterState == I2C_STARTED ) { I20DAT = I2CMasterBuffer[1+WrIndex]; WrIndex++; I2CMasterState = DATA_ACK; } I20CONCLR = I2CONCLR_SIC; break;

case 0x28: /* Data byte has been transmitted, regardless ACK or NACK */ case 0x30: if ( WrIndex != I2CWriteLength ) { I20DAT = I2CMasterBuffer[1+WrIndex]; /* this should be the last one */ WrIndex++; if ( WrIndex != I2CWriteLength ) { I2CMasterState = DATA_ACK; } else { I2CMasterState = DATA_NACK; if ( I2CReadLength != 0 ) { I20CONSET = I2CONSET_STA; /* Set Repeated-start flag */ I2CMasterState = I2C_REPEATED_START; } } } else { if ( I2CReadLength != 0 ) { I20CONSET = I2CONSET_STA; /* Set Repeated-start flag */ I2CMasterState = I2C_REPEATED_START; } else { I2CMasterState = DATA_NACK; } } I20CONCLR = I2CONCLR_SIC; break;

case 0x40: /* Master Receive, SLA_R has been sent */ I20CONCLR = I2CONCLR_SIC; SCS = 0x01; FIO0DIR = 0x0000003E; FIO0SET = 0x0000003E; for (i = 0;i<= 100000000;i++) break;

case 0x50: /* Data byte has been received, regardless following ACK or NACK */ case 0x58: I2CMasterBuffer[3+RdIndex] = I20DAT; RdIndex++; if ( RdIndex != I2CReadLength ) { I2CMasterState = DATA_ACK; } else { RdIndex = 0; I2CMasterState = DATA_NACK; } I20CONSET = I2CONSET_AA; /* assert ACK after data is received */ I20CONCLR = I2CONCLR_SIC; break;

case 0x20: /* regardless, it's a NACK */ case 0x48: I20CONCLR = I2CONCLR_SIC; I2CMasterState = DATA_NACK; break;

case 0x38: /* Arbitration lost, in this example, we don't deal with multiple master situation */ default: I20CONCLR = I2CONCLR_SIC; break; } IDISABLE; VICVectAddr = 0; /* Acknowledge Interrupt */
}

0