LPCxpresso i2c monitor mode

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPCxpresso i2c monitor mode

542 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ayia on Tue Aug 07 01:23:08 MST 2012
Hi,

Can you please share some examples of the I2C monitor mode using LPC11C24. Thank you very much.

-Wei
0 Kudos
1 Reply

480 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ayia on Wed Aug 15 04:50:10 MST 2012
Hi Everyone,
Update: the monitor is listening the traffic between a master continuously reading 4 bytes measurements from a sensor (with address 0x78). Based on some examples I got, my configuration is:

  LPC_I2C->ADR0 = 0xF1; // 0x78<<1 + 1
  // Monitor mode
  LPC_I2C->MMCTRL = MM_ENA;
  /* Configure interrupt for I2C in NVIC of ARM core */
  NVIC_EnableIRQ(I2C_IRQn);
  /* Enable I2C operation */
  LPC_I2C->CONSET = I2CONSET_I2EN |I2CONSET_SI;


My interrupt routine:
  ...
  ToggleGPIOBit( 2, 6 );
  switch ( StatValue ){
   case 0xA8:
   WrIndex = 0;
   I2CWrBuffer[WrIndex++] = LPC_I2C->DAT;
   break;

   case 0xB8:
   I2CWrBuffer[WrIndex++] = LPC_I2C->DAT;
   break;

   case 0xC0:
   I2CWrBuffer[WrIndex++] = LPC_I2C->DAT;
   break;
  ...
  }
  LPC_I2C->CONSET = I2CONSET_AA;
  LPC_I2C->CONCLR = I2CONCLR_SIC;
  ToggleGPIOBit( 2, 6 );

My interrupts work fine with the I2C state changes from 0xA8->0xB8->0xB8->0xB8->0xC0->...

The problem is that I can not get the correct readings from neither the DAT nor the DATA_BUFFER registers. Sometimes, I get zeros or totally wrong values. I have a timing diagram attached (the yellow channel presents the times when the interrupts happen, and the red and blue channels are SDA and SCL). Take this diagram as an example, the readings from the buffer are 49 and 161, which are incorrect compared to the diagram. Can anyone give me some suggestions?

Regards,
Wei
0 Kudos