LPC804 I2C slave example does not respond

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

LPC804 I2C slave example does not respond

1,605 Views
KoComputes
Contributor II

I'm new to the LPC844 and I am designing an interrupt driven I2C slave (or should I say: 'peripheral'?) device, listening to I2C address 0x78. The problem is that the I2C example code responds with 'NACK' when it's addressed by the master. I hope this forum is a good place to get a bit of support.

I took the LPCXpresso804 board and tried to run the SDK example "lpc_i2c_interrupt_b2b_transfer_slave".

In line 23 of the example code I changed the value of 0x7EU to 0x78U :

 

#define I2C_MASTER_SLAVE_ADDR_7BIT (0x7EU)

 

I triple checked the hardware connections: the on-board I2C temperature sensor is disconnected, pull-up resistors are present, voltage levels OK. The pins that I'm connecting to correspond to the pins mentioned in the example.

Other checks: the program really runs, based on the debug output window; the I2C master program is able to send out I2C communication succesfully (including acks etc.).

The trace in the logic analyser is shown in the attachment. It always shows no ACK at the end of the address. This trace is also seen when the I2C lines are disconnected from the LPCXpresso board.

Questions:

- what else should I adjust in the example code to get it to work?

- the master runs at 400 kbps. Should I / can I set the slave to correspond to that speed? Is it relevant at all for a slave device?

Thanks!

0 Kudos
6 Replies

1,559 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello

I will gladly help you with this.
I perform some tests with the LPC804 as a slave and the LPC54628 as master with the bus speed at 400kHz.
In the slave, I added this line, if this line is not added the slave will not respond to the master

nxf54944_0-1615322131935.png

Since I was doing a board-to-board communication I did not add the pull-up resistors since they are internally in the pins. Having a common ground between both devices is suggested.

Let me know if adding this line in the slave solves your problem, if you have more questions do not hesitate to ask me.
Best regards,
Omar

1,578 Views
KoComputes
Contributor II

Thanks very much, Frank.

- I checked the address using the master example. That example emits the address correctly and uses the same #define.

- The hardware and the example allow 400 kHz. Changed that setting in the example as well; no effect.

- Pull-ups are 2.2k, so we agree on that value.

I proceed with different example code, see if they work better.

0 Kudos

1,574 Views
frank_m
Senior Contributor III

Without proper hardware, I can just share some basic comments ...

You could try to left-shift the address value, and see how the device responds to a read access.

For me, getting an I2C device to work often involved some trial-and-error tests.

0 Kudos

1,598 Views
frank_m
Senior Contributor III

I have not worked with the I2C interface of LPC controllers for a long time, but ...

#define I2C_MASTER_SLAVE_ADDR_7BIT (0x7EU)

As you see, this is a 7-bit address, not 8-bit. The LSB of the I2C is formed by the access type, i.e write (0) or read (1). 

Some manufacturers define the I2C addresses quasi as 8-bit value, where the R/W bit is combined in. Others imply a left-shift. You would need to read both specs. (LPC804 I2C peripheral and slave device) carefully.

Second, check the slave actually supports fast mode (400kHz). Standard mode is 100kHz.

Third, I suppose proper pull-up resistors are present. For me, 2..5k used to work best. Pull-ups are essential for the I2C bus.

I know, I2C can be frustrating to bring up. Almost every mistake results in NACK.

1,561 Views
KoComputes
Contributor II

Frank, thank you for the suggestions! 
- 7 bit address: yes I'm aware. I compiled the I2C Master example and got that working. In that example I updated the address as described above, and it worked. Of course the I2C slave example could have a different implementation behind the similarly named #define but for now I assume that that is not the case.

- pull-ups: they're 2.2k

- baud rate: yes LPC804 is capable of 100 kHz and 400 kHz rates. Adjusting it in code did not help. Running the master at 100 kHz instead of 400 kHz also doesn't help.

I don't like to pose the hypothesis that there is a bug in the example software, but that is one of the few possibilities left. So I'm going to give a different example a try: https://mcuxpresso.nxp.com/api_doc/dev/116/group__i2c.html

If anybody knows a piece of properly tested I2C slave code for LPC8xx, it would be great if that is shared.

0 Kudos

1,552 Views
KoComputes
Contributor II

Thanks for all replies. There was a hardware issue in my setup. After fixing the intermittent contact of a pull-up resistor the device responds with A-ACK. Nice!

The data reported by the example is not the data that I see on the bus. If needed I will come back to that.

 

0 Kudos