Content originally posted in LPCWare by vladimirro on Sat Nov 21 14:49:40 MST 2015
Hello all
I tried to set up I2C connection between my LPC1114 and the other device and I totally gave up.
Let me paste you my init function
void i2cinit()
{
LPC_SYSCON->PRESETCTRL |= I2C_RST_N;//deaserting I2C
LPC_IOCON->PIO0_4 |= (0x1);//pio0_4 scl
LPC_IOCON->PIO0_5 |= (0x1);//pio0_5 sda
LPC_I2C->CONCLR |= I2C_ACKC | I2C_SIC | I2C_STAC | I2C_ENC;
LPC_I2C->SCLH = 100;//high duty cycle
LPC_I2C->SCLL = 100;//low duty cycle
LPC_I2C->CONSET |= I2C_EN;//I2C enable
}
Clock is 48MHz and and I2C is turned on (#define AHBCLKCTRL_Val 0x000107FF)
Now, since nothing is working I tried to scope PIO0_4 and PIO0_5 to see if there's any reaction on those pins.
I tried to do this:
if (!(LPC_GPIO1->DATA & SWITCH1)) LPC_I2C->CONSET |= I2C_STA;
After pressing SWITCH1 SDA should go low and SCL should start oscilating? Am I right? Unfortunately both pins stay high...