LPI2C NACK issue

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
3,156件の閲覧回数
m_mishrikey
Contributor III

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

 

 

 

ラベル(1)
0 件の賞賛
返信
1 解決策
3,127件の閲覧回数
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

元の投稿で解決策を見る

5 返答(返信)
3,139件の閲覧回数
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 件の賞賛
返信
3,137件の閲覧回数
m_mishrikey
Contributor III

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 件の賞賛
返信
3,128件の閲覧回数
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

3,119件の閲覧回数
m_mishrikey
Contributor III

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 件の賞賛
返信
3,116件の閲覧回数
m_mishrikey
Contributor III

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

Thanks again.

 

0 件の賞賛
返信