This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I2C peripheral not working with real hardware, but seems to in the simulator

Hi,
I can't get the I2C peripheral to work on an NXP LPC1114/301. I have reduced the code down to a simple test which sets the I2C speed registers I2C0SCLH and I2C0SCLL. This works when run in simulator mode - looking at memory address 0x40000010 and 0x40000014, and the I2C 0 Interface peripheral status box the code works; also the memory here is writable and changing the value changes the I2C peripheral values.
However when running the code on the target (actually the processor end of a LPC1114 LPC XPresso board and Keil Ulink 2) both the memory and I2C peripheral status remain unchanged. Changing the memory location 0x40000010, which begins with the default value of 4, just changes back to 4. The same happens if you try to change I2C0SCLL/H in the I2C peripheral box.
The target has been running code successfully (UART, timers, capture compare etc.) so seems pretty much alive.
Here's the test code:

#include "lpc11xx.h"

int main(void)
{
  SystemInit();

  LPC_GPIO1->DIR            = 0xEBE;
  LPC_GPIO2->DIR            = 0x7FF;
  LPC_GPIO3->DIR            = 0;
  LPC_IOCON->RESET_PIO0_0   = 0x30;  // RESET function
  LPC_IOCON->PIO0_4         = 0x01;  // SCL, Fast mode I2C
  LPC_IOCON->PIO0_5         = 0x01;  // SDA, Fast mode I2C
  LPC_IOCON->SWCLK_PIO0_10  = 0;     // SWD
  LPC_IOCON->SWDIO_PIO1_3   = 0x80;

  // I2C

  LPC_I2C->SCLH             = 60;    // 400kHz, 50% duty
  LPC_I2C->SCLL             = 60;
  LPC_I2C->CONCLR           = 0xFF;  // clear all I2C control bits

  while (1);
}


I look forward to fixing this, it's been bugging me for days :-(
I'm wondering if I haven't set up something somewhere. The I2C clock is enabled in system_LPC11xx.c.
The chip has a 12MHz crystal and 4x PLL so it's running at 48MHz.

Thanks,
John