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:
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?
Solved! Go to Solution.
The slave address is 7 bits. You should use 0x20 as the slave address. Would you please have a try?
Hi m_mishrikey,
The SDA is high at the second raising edge of SCL. The waveform of PIC i2c demo.
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!
-----------------------------------------------------------------------------------------------------------------------
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:
(image above off internet).
The code I am using is straightforward:
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.
The slave address is 7 bits. You should use 0x20 as the slave address. Would you please have a try?
Yes!!
Now I just need to figure out why the LEDs are not illuminating on that expander...
But this is much much better!
Thanks Robin.
Ah. I needed to send the stop bit. LEDs work now.
Thanks again.