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 / How to read 16 bit of data using I2C/TWI Protocol

How to read 16 bit of data using I2C/TWI Protocol

|

Microcontroller › AVR › How to read 16 bit of data using I2C/TWI Protocol

  • This topic has 1 reply, 2 voices, and was last updated 9 years, 11 months ago by Vara Ashishkumar.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • November 15, 2015 at 4:27 am #4104
    Amit
    Participant

    Hi friends

     I have slave device INA219 which has 16 bit resister, and i have to read this 16 bit resister using I2C/TWI Protocol

    my confussion is I2C has Data resister(TWDR) 8bit then how to read 16 bit ?

     

    Here i have written I2C/TWI Read function 

     

     

    void TWI_read_data(void)
    {
    TWCR=(1<<TWINT)|(1<<TWEN);    // Clear TWI interrupt flag,Enable TWI
    while (!(TWCR & (1<<TWINT))); // Wait till complete TWDR byte transmitted
    while((TWSR & 0xF8) != 0x58); // Check for the acknoledgement
    recv_data=TWDR;
    PORTB=recv_data;
     
    November 19, 2015 at 12:35 pm #13499
    Vara Ashishkumar
    Participant

    Hye Amit,

    I2C protocol read single byte at a time. INA219 has 16 bit register which is acess in two 8 bytes via I2C Interface. As my opinion repeat two time process of read data.

    Try it….

     

  • 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

  • strange laptop problem November 9, 2025
  • JLCPBC are using a different shipping company = less $$$$$$$$ November 9, 2025
  • Manually actuate fuel tank selector solenoid November 9, 2025
  • Help please! BLDC driver circuit using the IR2136s and the STP80NF06 MOSFETS November 8, 2025
  • need two ICs November 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