lpcware

I2C Interrupt

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by adrian0211 on Fri Mar 14 15:03:10 MST 2014
Hello,
I need help with the i2c bus. First i implemented the initializing:
void I2C_Init()
{
LPC_SYSCON->PRESETCTRL |= PRESETCTRL_I2C_RST_N;// I2C reset de-asserted
LPC_SYSCON->SYSAHBCLKCTRL |= SYSAHBCLKCTRL_I2C;// Enables Clock for I2C

LPC_IOCON->PIO0_4 |= 0x10;// I2C SCL
LPC_IOCON->PIO0_5 |= 0x10;// I2C SDA

LPC_I2C->CONCLR |= I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC;//Init I2C Reg

LPC_I2C->SCLL   = I2SCLL_SCLL;// configuration I2C Bus Frequency
LPC_I2C->SCLH   = I2SCLH_SCLH;// configuration I2C Bus Frequency

NVIC_EnableIRQ(I2C_IRQn); // Enable the I2C Interrupt

LPC_I2C->CONSET = I2CONSET_I2EN;//Enable I2C Interface

return;
}

That seems to work. ...Then I wrote an I2C_IRQHandler to handle the interrupt states. (I use the microcontroller as Master only!)
The implemented states are 0x8, 0x10, 0x18, 0x28,...
After setting the Startbit I expected a state of 0x8. The manual says that the SI (interruption) bit is set automatically.
But I neither get a state of 0x8 nor enter the interrupt routine.

Would be thankful for some help.
If you want to see some more code i can publish the hole project.


Adrian




Outcomes