Giter Site home page Giter Site logo

i2c_demo's Introduction

Overview

This project demonstrates some advanced I2C concepts, discussed [here] 1.

Timing

Using the default transmission rate, the I2C clock runs at 100kHz, which translates to ~96us/byte of actual payload. This timing takes the overhead padding the payload into account.

By using a clock rate of 400kHz instead, the transmission speed increases to ~28us/byte. As shown in the file master_writer/master_writer.ino, the clock-rate can be set by modifying the contents of the TWBR-register (search for TWBR [here] 1).

To demonstrate the usage of 400kHz clock-rate, load the master_writer project on one device and load the slave_receiver onto another device and connect a serial terminal to the slave_receiver device. You should see output similar to:

x is 1
x is 2
x is 3
x is 4
x is 5
...
...
...
x is 254
x is 254
x is 1
x is 2
x is 3
...

NB See i2c-SCL-TWBR_default.pdf and i2c-SCL-TWBR_12.pdf to show that the clock-rate does indeed change when changing TWBR.

Broadcast

By default, a slave receiver only responds to transmissions sent to the slave's specific address. However, as described [here] 1, by setting the lowest bit of the slave's TWAR register to 1, the slave will also respond to any transmissions to address 0x00, which is reserved as a special, broadcast address.

To demonstrate the sending and receiving of a broadcast message, load the control_board project on one device and load the extension_module onto one (or more) device(s) and connect a serial terminal to the extension_module devices. You should see output similar to:

broadcast: 1
broadcast: 2
broadcast: 3
broadcast: 4
broadcast: 5
...
...
...
broadcast: 254
broadcast: 254
broadcast: 1
broadcast: 2
broadcast: 3
...

NB Just to reiterate, the broadcast messages are not sent to a specific slave-device address. Instead, the slave-devices are configured to listen to broadcast messages and the master-device sends out a broadcast message by transmitting to address 0x00.

i2c_demo's People

Contributors

cfobel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.