Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

jani12

Advanced Member level 4
Joined
Oct 30, 2014
Messages
107
Helped
0
Reputation
0
Reaction score
1
Trophy points
1,296
Activity points
2,527
NXP LPC11E68JBD48E Microcontroller I2C1 is Master. I2C1 is in chapter 13. I2C1 is in Master Transmitter Mode.
https://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

byte_sent.PNG
 

Attachments

  • step1_Master_Transmitter_Mode.PNG
    step1_Master_Transmitter_Mode.PNG
    10.3 KB · Views: 209
  • step2_start_bit_sent.PNG
    step2_start_bit_sent.PNG
    10.6 KB · Views: 95
  • step3_status_0x08_state_handler.PNG
    step3_status_0x08_state_handler.PNG
    8.8 KB · Views: 106
  • step4a_NAK_from_slave.PNG
    step4a_NAK_from_slave.PNG
    11.4 KB · Views: 178
  • step4b_NAK_handler.PNG
    step4b_NAK_handler.PNG
    4.7 KB · Views: 99

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 bitlpc11e68_Master_pca6408_slave_addr_byte.PNG. 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_pcal6416_slave_no_start_bit.PNG

lpc11e68_Master_pca6408_slave_addr_byte.PNG
 

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

    jani12

    Points: 2
    Helpful Answer Positive Rating
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
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top