I2C monitor mode

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

I2C monitor mode

2,328 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Marius on Wed Aug 11 19:20:54 MST 2010
I would like to use the LPC1343 to monitor the activity on an existing I2C bus and output logs through the UART IF
The user manual doesn't provide any example on how to use the monitor mode.
Has anybody tried the monitor mode in I2C?

Thank you
0 Kudos
15 Replies

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Seba on Wed Sep 11 04:03:50 MST 2013
I faced the same problem. My workaround is to write 0xFF to DAT register after reading DATA_BUFFER in interrupt routine ("Own SLA+R has been received" and "Data byte in I2DAT has been transmitted" interrupts).
0 Kudos

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Leji on Fri May 27 05:14:30 MST 2011
Indeed my previous code only implements monitoring of writes, at the time I was only interested by these :)
But now that I'm also interested by reads I'm facing the same issue as you guys, it seems impossible using "normal" ways... Did anyone find a workaround ?
0 Kudos

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by atomicdog on Sun May 22 00:11:24 MST 2011
After experimenting with monitor mode on the LPC1114 it looks like monitoring the slave TX isn't easy (possible?).  The [I]AA[/I] bit needs to be cleared in order for [I]LPC_I2C->DATA_BUFFER[/I] to have the correct data. The problem is [I]AA[/I] needs to be set for [I]SI[/I]  (and interrupts) to happen. So far I haven't been able to find a way to detect a change in [I]DATA_BUFFER.[/I]
0 Kudos

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Marius on Wed May 18 15:12:30 MST 2011

Quote: cmcquaid
Marius,

I have tried to implement I2C monitor mode on an LPC1768, 1769 and 1114. In each case I see the same behavior. My setup has the microcontroller attached to an I2C bus on which there is an I2C protocol emulator (Totalphase Aardvark) and an eeprom. When the emulator writes to the eeprom, the data is captured correctly but when reading from the eeprom, the data sent by the slave is not seen correctly although interrupts occur in the proper places.

A colleague has also made an independent attempt to implement a monitor, but with the same results. I have also tried Leji's code above to no avail.

I can supply you with code to monitor the bus and write to the uart, so long as you don't care about slave reads.

I would be extremely interested in hearing of a successful monitor implementation.




Thx. for the reply. I implemented a I2C bus sniffer and I have the same issue : read access data phase is corrupt. I was wondering if my code is wrong but this confirms LPC1343 I2C monitor function doesn't work as expected.
I asked the NXP FAE but I have got no answer.

Has anyone tried the I2C monitor mode on other LPCs successfully?
0 Kudos

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by atomicdog on Tue May 10 22:56:31 MST 2011

Quote: cmcquaid
Hi John,

I've tried both DAT and DATA_BUFFER, although perhaps not both combinations on all the platforms I mentioned.

I just checked again, both ways on the I2C2 port of an LPC1114 on an lpcxpresso board and I get zeroes during a slave read.

Which port are you using, and would you care to share some details of your code or setup?

Thanks

The  LPC1114 only has one I2C port.
I did a small modification to this code I posted by setting up MMCTRL.
  // Monitor mode
  LPC_I2C->MMCTRL = (1<<0) | (1<<2);

  while ( !((I2cRxBuff.tail-I2cRxBuff.dptr) & I2C_RX_RING_BUFFER_SIZE) );//- wait for full buffer
0 Kudos

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cmcquaid on Tue May 10 16:06:58 MST 2011
Hi John,

I've tried both DAT and DATA_BUFFER, although perhaps not both combinations on all the platforms I mentioned.

I just checked again, both ways on the I2C2 port of an LPC1114 on an lpcxpresso board and I get zeroes during a slave read.

Which port are you using, and would you care to share some details of your code or setup?

Thanks
0 Kudos

1,844 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by atomicdog on Tue May 10 14:15:28 MST 2011

Quote:

A colleague has also made an independent attempt to implement a monitor,  but with the same results. I have also tried Leji's code above to no  avail.

Are you using DATA_BUFFER or DAT to read the data?
[SIZE=1]
[COLOR=Silver]I'm able to monitor (with correct data) the bus transactions for both read and write between an Aardvark and an EEPROM.[/COLOR][SIZE=3]EDIT: Correct data only happens when the AA bit is off.[/SIZE]
[/SIZE]
0 Kudos

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cmcquaid on Tue May 10 13:33:21 MST 2011

Quote: marius
I would like to use the LPC1343 to monitor the activity on an existing I2C bus and output logs through the UART IF
The user manual doesn't provide any example on how to use the monitor mode.
Has anybody tried the monitor mode in I2C?

Thank you


Marius,

I have tried to implement I2C monitor mode on an LPC1768, 1769 and 1114. In each case I see the same behavior. My setup has the microcontroller attached to an I2C bus on which there is an I2C protocol emulator (Totalphase Aardvark) and an eeprom. When the emulator writes to the eeprom, the data is captured correctly but when reading from the eeprom, the data sent by the slave is not seen correctly although interrupts occur in the proper places.

A colleague has also made an independent attempt to implement a monitor, but with the same results. I have also tried Leji's code above to no avail.

I can supply you with code to monitor the bus and write to the uart, so long as you don't care about slave reads.

I would be extremely interested in hearing of a successful monitor implementation.
0 Kudos

1,844 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by atomicdog on Thu May 05 20:38:08 MST 2011

Quote: Leji
...So I always need to have a data byte to know if the address was ACKed, which is not what I want (The chip I want to monitor "pings" I2C devices to see if they are populated by just checking if the address is ACKed or not, without sending actual data)

I think you're out of luck then. Unless you want to get creative and use a timer and an extra I/O pin to check the Ack bit.

This Phillips I2C state machine hardware block is really old. It looks to me like it was ported over from their parallel-to-I2C IC but Phillips didn't really make it microcontroller friendly.
I think NXP is long overdue in creating a new one with modern features like the one you need.
0 Kudos

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Leji on Thu May 05 06:07:51 MST 2011
That's what I expected, but I always get 0xA0. I do get 0x80 after the first data byte is acknowledged, but not after the address was.
So I always need to have a data byte to know if the address was ACKed, which is not what I want (The chip I want to monitor "pings" I2C devices to see if they are populated by just checking if the address is ACKed or not, without sending actual data)



Quote: atomicdog
If it goes from 0x60 to 0xA0 then it was  'No Ack'.
If it goes from 0x60 to 0x80 then it's an Ack.

0 Kudos

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Wed May 04 22:14:26 MST 2011

Quote: bharat.gopani
Hi ,
I am using LPCXpresso Compiler for LPC1768

Example Project is build properly but hex file is not created .

so anybody can help me for how to create hex file in LPCXpresso Compiler ?



@bharat.gopani I agree with marius's request that you create your own thread.

Delete your post in this thread and create a new thread and I will try to help you in the new thread. OK?
0 Kudos

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by atomicdog on Wed May 04 20:22:10 MST 2011

Quote: Leji
Hi,

I got the I2C monitor working the LPC1768 using following code and handling the data read in void I2C0_IRQHandler(void). I still have one issue to address though:
I can't find a way to determine if an address was acknowledged or not.

I always get status 0x60, whether the address was acked or not, and I don't see any difference in the I2C registers between the two cases. Is it just impossible ?


If it goes from 0x60 to 0xA0 then it was  'No Ack'.
If it goes from 0x60 to 0x80 then it's an Ack.
0 Kudos

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Leji on Wed May 04 02:24:43 MST 2011
Hi,

I got the I2C monitor working the LPC1768 using following code and handling the data read in void I2C0_IRQHandler(void). I still have one issue to address though:
I can't find a way to determine if an address was acknowledged or not.

I always get status 0x60, whether the address was acked or not, and I don't see any difference in the I2C registers between the two cases. Is it just impossible ?

// enable power
    LPC_SC->PCONP |= (1 << 7);

    // set pin mux
    LPC_PINCON->PINSEL1 &= ~((0x03<<22)|(0x03<<24));
    LPC_PINCON->PINSEL1 |= ((0x01<<22)|(0x01<<24));

    // Clear flags
    LPC_I2C0->I2CONCLR = (1<<2) | (1<<3) | (1<<5) | (1<<6); // I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC

    // Slave mode
    LPC_I2C0->I2ADR0 = 0x12;
    LPC_I2C0->I2MASK0 = 0x7F;

    // Monitor mode
    LPC_I2C0->MMCTRL = (1<<0) | (1<<2);

    // Setup interrupt
    NVIC_EnableIRQ(I2C0_IRQn);

    // Enable I2C interface
    LPC_I2C0->I2CONSET = 0x44;
0 Kudos

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Marius on Mon Aug 16 06:01:02 MST 2010
Hey Bharat,
Your request has nothing to do with the original thread : "I2C monitor mode".
Please use a separate thread for your request.
Thank you
0 Kudos

1,845 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bharat.gopani on Thu Aug 12 00:28:14 MST 2010
Hi ,
I am using LPCXpresso Compiler for LPC1768

Example Project is build properly but hex file is not created .

so anybody can help me for how to create hex file in LPCXpresso Compiler ?
0 Kudos