EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / I2C protocol ACK problem

I2C protocol ACK problem

|

Microcontroller › AVR › I2C protocol ACK problem

  • This topic has 1 reply, 2 voices, and was last updated 7 years, 3 months ago by GANEEV SINGH.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • June 9, 2017 at 5:09 am #4664
    s.manisrinivas
    Participant

    hi friends,i am using eeprom 24c64 and atmega32 avrstudio.

    after 7-bit address and r/w 1-bit ,master is  acknowledging (ack 0x18) , but data 8-bit and 1-bit for ack (0x28)  is not getting ,if you give NACK (0x30) i  am getting .

     

    my doubt is after data i.e. 8-bit and 1-bit ack ,master has to ack or is it okay master gives NACK also.

     

    unsigned char i2c_sendData(unsigned char data)
    {
     
    TWDR = data;
    TWCR = (1<<TWINT) |(1<<TWEN);   //Load SLA_W into TWDR Register. Clear TWINT bit
    //in TWCR to start transmission of data
    while (!(TWCR & (1<<TWINT)));   //Wait for TWINT flag set. This indicates that the
    //data has been transmitted, and
    //ACK/NACK has been received.
     
    if ((TWSR & 0xF8) != MT_DATA_NACK)   //Check value of TWI Status Register
    return(0);
    else
    return(1);
    }

    if you give (mt_data_Nack) it is returning 0 if you give (mt_data_ack) it returning 1.why?

    March 15, 2018 at 6:46 am #14795
    GANEEV SINGH
    Participant

    Hi

    There is no such predefined status "MT_DATA_NACK". It is either MT_SLA_ACK (slave's address acknowledgement) or MT_SLA_DATA (data achnowledgement).

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Raise your hand if your car had one of these: July 8, 2025
  • Tektronix 2235 channel 1 trace unstable July 8, 2025
  • How to make string LEDs? July 8, 2025
  • Wideband matching an electrically short bowtie antenna; 50 ohm, 434 MHz July 8, 2025
  • The Analog Gods Hate Me July 8, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise