LPI2C NACK issue

cancel
Showing results for 
Search instead for 
Did you mean: 

LPI2C NACK issue

Jump to solution
460 Views
m_mishrikey
Contributor II

Hello, 

I am attempting to get basic LPI2C conversations going and am having some difficulty.  I'm still trying to determine if the issue is hardware or software related.  

I send a valid I2C write, but after the initial address byte I get a NACK, and that's the end of it.  

The slave is connected and has an address matching the address written to.  

I've tried blocking and non-blocking sends, and tried with and without stop bit.  I am using SDK 3.0.3.

Here is an example with stop bit between sends:

m_mishrikey_0-1599020575201.png

One thing I am curious about is when I compare this to a PIC i2C demo board, there is quite a gap between data bytes:  I guess that's just up to the slave.  But how do you control this duration for master writes, using the SDK?

m_mishrikey_1-1599020669913.png

 

 

 

Labels (1)
0 Kudos
1 Solution
431 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

The slave address is 7 bits. You should use 0x20 as the slave address. Would you please have a try?

MCP23008.png7 bit slave address.png

View solution in original post

5 Replies
443 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi m_mishrikey,

ACK.pngThe SDA is high at the second raising edge of SCL. The waveform of PIC i2c demo.

 

NAK.png
The SDA is high at the first raising edge of SCL. The waveform of S32K.

Would you please check if the slave address is 0x40 or 0x20?

Best Regards,
Robin

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
441 Views
m_mishrikey
Contributor II

The address I am trying to write to is 0x40, which is the slave address for the MCP23008 expander on the pic serial demo board: 

m_mishrikey_0-1599147310544.png

(image above off internet).  

 

The code I am using is straightforward: 

m_mishrikey_1-1599147386986.png

I do two sends; one is to address 0, instructing all port pins to be outputs. The second instruction is to address 0x09, writing 0xEE to GPIO pins (0b11101110).  

One the image I sent previously, you can see the address 0x40 of the first send, followed by NACK, and the address of the second send, also 0x40, followed by NACK.  

 

 

0 Kudos
432 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

The slave address is 7 bits. You should use 0x20 as the slave address. Would you please have a try?

MCP23008.png7 bit slave address.png

View solution in original post

423 Views
m_mishrikey
Contributor II

Yes!!

m_mishrikey_0-1599220048472.png

Now I just need to figure out why the LEDs are not illuminating on that expander...

But this is much much better!

Thanks Robin.

0 Kudos
420 Views
m_mishrikey
Contributor II

Ah. I needed to send the stop bit.  LEDs work now. 

Thanks again.

 

0 Kudos