hello sir/mam, i want to use i2c interface for my project in which i m using the LPC2468 microcontroller. i m using keil software.i got one code for i2c that is as follows but in this i have some quaries can u please help me. code: #include "LPC213x.h" void initialize(void); __irq void I2C_ISR(void); /* Master Transmitter states */ void ISR_8(void); void ISR_18(void); void ISR_28(void); /*************************** MAIN ************************/ int main() { /* Initialize system */ initialize(); /* Send start bit */ I2C0CONSET=0x60; /* Do forever */ while(1) { IOCLR0=0x40; IOSET0=0x40; } } /*************** System Initialization ***************/ void initialize() { /* Remap interrupt vectors to SRAM */ MEMMAP=0x2; /* Initialize GPIO ports to be used as indicators */ IODIR0=0xF0; IOSET0=0xF0; /* Initialize Pin Connect Block */ PINSEL0=0x50; /* Initialize I2C */ I2C0CONCLR=0x6c; /* clearing all flags */ I2C0CONSET=0x40; /* enabling I2C */ I2C0SCLH=0xC; /* 100 KHz */ I2C0SCLL=0xD; /* Initialize VIC for I2C use */ VICIntSelect=0x0; /* selecting IRQ */ VICIntEnable= 0x200; /* enabling I2C */ VICVectCntl0= 0x29; /* highest priority and enabled */ VICVectAddr0=(unsigned long) I2C_ISR; /* ISR address written to the respective address register*/
} /********************** I2C ISR **************************/ __irq void I2C_ISR() { int temp=0; temp=I2C0STAT; switch(temp) { case 8: ISR_8(); break; case 24: ISR_18(); break; case 40: ISR_28(); break; default : break; } VICVectAddr=0xFF; } /* I2C states*/ /* Start condition transmitted */ void ISR_8() { /* Port Indicator */ IOCLR0=0x10; /* Slave address + write */ I2C0DAT=0x74; /* Clear SI and Start flag */ I2C0CONCLR=0x28; /* Port Indicator */ IOSET0=0x10; }
/* Acknowledgement received from slave for slave address */ void ISR_18() { /* Port Indicator */ IOCLR0=0x20; /* Data to be transmitted */ I2C0DAT=0x55; /* clear SI */ I2C0CONCLR=0x8; /* Port Indicator */ IOSET0=0x20; } /* Acknowledgement received from slave for byte transmitted from master. Stop condition is transmitted in this state signaling the end of transmission */ void ISR_28() { /* Port Indicator */ IOCLR0=0x80; /* Transmit stop condition */ I2C0CONSET=0x10; /* clear SI */ I2C0CONCLR=0x8; /* Port Indicator */ IOSET0=0x80; } /********************************************************/ in this code i m not getting what is I2C_ISR..in this code initialization is perfect but after that it is going to the infinite loop..in the startup code it is going in the infinite loop....and i m also not getting what is the meaning of LDR PC, [PC, #-0x0120]..after that while loop it is coming on this lable which is in the startup file and then not comming out....can u please help me..thank u.
hello sir, i have visited nxp..and this code is also provided by philips..i m also not getting why he had use that while loop??