i2c with lpc2148 and 24c02

Status
Not open for further replies.

shruv

Member level 2
Joined
Jun 13, 2013
Messages
47
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Visit site
Activity points
270
After setting the start bit the SI flag is not getting set.therefore not entering the isr routine. Can anyone tell me why?

Code:
void i2c_init()
{
		PINSEL0=BIT4+BIT6; //scl=port0.2 sda port0.3
		IODIR0=BIT2+BIT3;
		I2C0CONSET=BIT6; // enable 
		I2C0CONCLR=BIT5+BIT2;
		I2C0SCLH=75;
		I2C0SCLL=75;
	
	/*i2c interrupt enable*/
	VICIntSelect=0x00;
	VICIntEnable=BIT9;
	VICVectAddr4=(unsigned) slave_addr;
	VICVectCntl4=0x29;
}
void read()
{
	lcd_data('r');	
	I2C0CONSET|=BIT5; // START BIT
	lcd_data('s');
}
__irq void slave_addr(void)
{
	
	I2C0CONCLR=BIT5; // clear the start bit
									
		switch(I2C0STAT)
		{
			case 0x08 : 
					I2C0DAT=0xa0;
							break;
                 }
         I2C0CONCLR=BIT3; // clr si flag
	VICVectAddr = 0x00;
}
	
int main()
{
	i2c_init();
	lcd_init();
	lcd_data('m');
	read();
}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…