Why does I2C Expander send NAK when master writes a byte?

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

Why does I2C Expander send NAK when master writes a byte?

1,341 Views
anaseem
Contributor IV
NXP LPC11E68JBD48E Microcontroller I2C1 is Master. I2C1 is in chapter 13.  I2C1 is in Master Transmitter Mode.
http://www.mouser.com/ds/2/302/UM10732-315822.pdf
NXP PCAL6416A I2C 16-bit I/O Expander is Slave.  https://www.nxp.com/docs/en/data-sheet/PCAL6416A.pdf
I2C1 Block in Microcontroller is initialized successfully.
Step 1.  I2C1 block is in master transmitter mode because I2C control Register STA bit is set to 1.  See attached step1_Master_Transmitter_Mode.png file.
Step 2.  Microcontroller I2C1 block transmits START bit.  After the START bit is transmitted, the Serial Interrupt(SI) bit in I2C Control Register is set and STAT register in microcontroller I2C1 block contains status of 0x08.  See attached filename step2_start_bit_sent.png
step 3.  The status 0x08 is used to vector to a state service routine.  This routine loads the slave address and Write bit to the DAT register.  See attached filename step3_status_0x08_state_handler.png
step 4.  Slave address and Write bit has been transmitted and negative acknowledgement(NAK) is received from slave.  The STAT register has status of 0x20 and microcontroller fires interrupt on this status value.  See attached step4a_NAK_from_slave.png file and step4b_NAK_handler.png

This problem occurs the very first time Master tries to communicate with slave.
The previous hardware works fine with this microcontroller and NXP PCA6408AHKX I2C 8-bit Expander chip.  When this byte is written to I2C register, ACK is received.
New hardware is same as previous hardware except 16-bit I/O expander instead of 8-bit.
What might be the problem?  Is it hardware or software?  What are usually reasons for NAK in I2C communication?
Labels (2)
Tags (1)
4 Replies

1,194 Views
anaseem
Contributor IV

The byte I'm sending is 0x42. Seven most significant bits are slave address and least significant bit is write direction bit. Please see attached filename byte_sent.png

byte_sent.PNG

0 Kudos

1,194 Views
anaseem
Contributor IV
Attached are scope screenshots for existing hardware and new hardware.
With existing hardware, slave sends an ACK.
With new hardware, after START condition is transmitted, master fires an interrupt to inform software that START bit has been transmitted but I don't see it on SDA line.  I'm triggering on START bit.  What might be the problem?
Some inputs in the I2C expander chip are floating.  Is this preventing the START bit to appear on the SDA line?
From I2C expander datasheet:  "External resistors are required for inputs (on P Port) that may float.  Also, internal pull-up or pull-down may be used to eliminate the need for external components."
lpc11e68_Master_pca6408_slave_addr_byte.PNG
lpc11e68_Master_pcal6416_slave_no_start_bit.PNG
0 Kudos

1,193 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Amer,

Please check the datasheet of I2C Expander, whether send the right data to it.

Also you can attach your project, we will help to check the code.

BR

Alice

1,193 Views
anaseem
Contributor IV

Problem Solved:

First new board:  saw NAK in software

Second new board:  SCL and SDA no wiggling at all

Third and Fourth Board:  I2C communication working as expected

0 Kudos