+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Member level 3
    Points: 965, Level: 7

    Join Date
    Oct 2014
    Posts
    60
    Helped
    0 / 0
    Points
    965
    Level
    7

    Why does I2C Expander reply with NAK when master sends a byte?

    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
    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 NACK in I2C communication?

    - - - Updated - - -

    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

    Click image for larger version. 

Name:	byte_sent.PNG 
Views:	0 
Size:	2.2 KB 
ID:	155371

    •   AltAdvertisement

        
       

  2. #2
    Member level 3
    Points: 965, Level: 7

    Join Date
    Oct 2014
    Posts
    60
    Helped
    0 / 0
    Points
    965
    Level
    7

    Re: Why does I2C Expander reply with NAK when master sends a byte?

    Attached are scope screenshots with 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 bitClick image for larger version. 

Name:	lpc11e68_Master_pca6408_slave_addr_byte.PNG 
Views:	9 
Size:	5.8 KB 
ID:	155449. 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."

    Click image for larger version. 

Name:	lpc11e68_Master_pcal6416_slave_no_start_bit.PNG 
Views:	5 
Size:	3.6 KB 
ID:	155450

    Click image for larger version. 

Name:	lpc11e68_Master_pca6408_slave_addr_byte.PNG 
Views:	9 
Size:	5.8 KB 
ID:	155449



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 260,224, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,441
    Helped
    13826 / 13826
    Points
    260,224
    Level
    100

    Re: Why does I2C Expander reply with NAK when master sends a byte?

    Slave can block I2C bus by pulling SDA low (or SCL, if it has an an SCL driver). Did you check?


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  4. #4
    Member level 3
    Points: 965, Level: 7

    Join Date
    Oct 2014
    Posts
    60
    Helped
    0 / 0
    Points
    965
    Level
    7

    Re: Why does I2C Expander reply with NAK when master sends a byte?

    Problem Solved:

    New board #1: saw NAK in software ISR
    New board #2: SCL and SDA not wiggling at all
    New boards #3 and #4: I2C Communication appears to be working as expected



--[[ ]]--