Hi @VaneB I think I have made almost everything you mentioned below (you can check it in my first post)
- Provide main_clk as function clock to I2C0
SYSCON->FCLKSEL[5]=0x0; // i2c clock selection: main clock
- Enable bus clocks to I2C0 and SWM
SYSCON->SYSAHBCLKCTRL0|=(1<<5); /* enable clock to I2C0 */
SYSCON->SYSAHBCLKCTRL0|=(1<<7); // Enable SWM clock
SWM0->PINENABLE0&=~(1<<12); /* connect I2C0_SDA to PIO0_11 */
SWM0->PINENABLE0&=~(1<<13); /* connect I2C0_SCL to PIO0_10 */
SYSCON->SYSAHBCLKCTRL0&=~(1<<7); /* disable clock to SWM */
SYSCON->PRESETCTRL0&=~(1<<5);
SYSCON->PRESETCTRL0|=(1<<5); /* reset I2C0 */
- Configure the I2C0 clock divider
I2C0->CLKDIV=500;
- Configure the I2C0 CFG register
I2C0->CFG=(1<<0); /* master mode */
- Enable the I2C0 slave pending interrupt
I am not sure about this. Why do I need a slave pending interrupt? I would like to do it in polling mode: when the MSTpending bit is 1 I write to the MSTDAT register.
This is the basic function that I would like to call in my main()
void i2c0_send_data(uint8_t devaddr,uint8_t value){
I2C0->MSTDAT=(devaddr<<1); // send address with R/W bit =0
I2C0->MSTCTL|=(1<<1); // send start
while(!(I2C0->STAT & 1)); /* wait for i2c0 idle or pending*/
I2C0->MSTDAT= value;
I2C0->MSTCTL=(1<<0); // send continue
while(!(I2C0->STAT & 1)); /* wait for i2c0 idle or pending*/
I2C0->MSTCTL|=(1<<2); // send stop
}
As I said before what I do not see working is this highlighted

At first, I doublechecked that the connections are good and probed the lines directly at the lpc pins but the oscilloscope shows that the i2c lines are always high.
Therefore I tried to do something more direct like this
while(1){
I2C0->MSTDAT=(14<<1); // send address with R/W bit =0
I2C0->MSTCTL|=(1<<1); // send start
}
I keep seeing the SCL and SDA lines stucked at 3v3 eventhough the start bit is set.

Therefore I tried to unplug and plug again the SDA pull-up external 2k2 resistor (i am using the LPC845brk on a breadboard) while the while loop was running and the SCL and SDA lines started sending the address. Indeed what I did was to force a start condition. So in my opinion there should be something that hinders having the start condition of the i2c (lpc does not put sda low) but I am not able to figure out what.
Do you have any idea that can help me?