I2C communication* I²C - Inter-Integrated Circuit – or –I squared C)

Slides:



Advertisements
Similar presentations
USERSPACE I/O Reporter: R 張凱富.
Advertisements

LOGO Lab Supervisor – Dr. WH Lau EE3271 Design Laboratory.
Lecture 8: Serial Interfaces
Serial Communication Buses: I 2 C and SPI By Brody Dunn.
I2CI2C CS-423 Dick Steflik. Inter-Integrated Circuit Developed and patented by Philips for connecting low speed peripherals to a motherboard, embedded.
Lecture 27: LM3S9B96 Microcontroller – Inter- Integrated Circuit (I 2 C) Interface.
Haptic Belt team Informational Presentation.  I 2 C is a form of control bus (multi-master) which allows communication between multiple integrated circuits.
Synchronous Serial IO Send a separate clock line with data
Team Members Jordan Bennett Kyle Schultz Min Jae Lee Kevin Yeh.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 10: Serial buses Oct 6, 2011.
1 © Unitec New Zealand I2C Lecture 10 Date: - 2 Nov, 2011 Embedded Hardware ETEC 6416.
Serial Peripheral Interface (SPI) Bus. SPI Bus There is no official specification for the SPI bus. It is necessary to consult the data sheets of the devices.
Arduino Nano to Uno I2C Communication Mike Pluma The-Bao Nguyen EE 444 Spring 2013.
LSU 10/22/2004Serial I/O1 Programming Unit, Lecture 5.
7/23 Inter-chip Serial Communication: SPI and I 2 C Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee.
EE 446 Project Assignment Top Design Sensor Components Pin Assignment and Configuration Completed Physical Setup Project Tasks.
GPIO interface From programmer’s view
Lecture 20: Communications Lecturers: Professor John Devlin Mr Robert Ross.
I/O Example: Disk Drives To access data: — seek: position head over the proper track (8 to 20 ms. avg.) — rotational latency: wait for desired sector (.5.
DEVICES AND COMMUNICATION BUSES FOR DEVICES NETWORK
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Real-time Systems Lab, Computer Science and Engineering, ASU Quark SPI Interface (ESP – Fall 2014) Computer Science & Engineering Department Arizona State.
©2008 R. Gupta, UCSD COSMOS Summer 2008 Peripheral Interfaces Rajesh K. Gupta Computer Science and Engineering University of California, San Diego.
HMC5883L TYWu.
Essentials of Communication This simple model requires many guarantees. Sender Receiver Communication Link Data.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
COMP 3438 – Part I - Lecture 5 Character Device Drivers
Tiltmeter, Compass,Temperature modules for the PPM.
Microcontroller basics Embedded systems for mortals.
I 2 C FOR SENSORS IN THE DOM Nestor Institute Koutsoumpos Vasileios - Nestor Institute 1.
“Success consists of going from failure to failure without loss of enthusiasm.” Winston Churchill.
 LED 를 직접 제어하는 디바이스 드라이버를 작성해 보자  Reminder: LED 는 SPI 를 통해 ARM7 과 연결된다. ◦ 그렇다면 고쳐야 하는 코드는 어디에 ?  linux-2.6.x/arch/arm/mach-nds/arm7 ◦ Hardware spec.
 The LPC2xxx devices currently have two on- chip UARTS.  Except UART1 has additional modem support.
Device Driver_Skeleton
Chapter 3 General-Purpose Processors: Software
Outline Analog to digital conversion (ADC) of NuMaker TRIO
Operating Systems Moti Geva
Serial Communication Buses: I2C and SPI
Manual for Arduino Kit v1.0
Chapter A - The Raspberry Pi Computer
Serial Communication Protocols And Embedded IoT
Socket programming Péter Verhás August 2002
Two Wire Interface Another popular serial peripheral interface bus
Chapter 22 – part a Stream refer to any source of input or any destination for output. Many small programs, obtain all their input from one stream usually.
Chapter 11: Inter-Integrated Circuit (I2C) Interface
Protection of System Resources
(Inter-IC bus) By Tejaswini Gadicherla
SERIAL PORT PROGRAMMING
Chapter D – Serial Connections to the RPi and Analog-to-Digital Converters
I2C Synchronous Serial Two wire communications (plus ground)
FILE LOCK #include <stdio.h> #include <stdlib.h>
I2C PROTOCOL SPECIFICATION
Communication Lines Fundamentals.
The Arduino Microcontroller: Atmel AVR Atmega 328
BJ Furman ME 106 Fundamentals of Mechatronics 15NOV2012
EEPROM Comparison – Parallel or Serial
NetSilicon & Digi Confidential
Yung-Hsiang Lu Purdue University
Displays and I2C(IIC) communications
Example 13 The Serial Peripheral Interface (SPI)
I2C and RTC Chapter 18 Sepehr Naimi
SPI Protocol Sepehr Naimi
Tutorial 3 Tutorial 3.
Programming Assignment # 2 – Supplementary Discussion
RPi 2/3, I2C, Analog Sensor
Another Physical Layer – I2C
Client-side Networking CSE 333 Summer 2018
Introduction to Arduino
File I/O & UNIX System Interface
I/O Experiments Assignment 1.
Presentation transcript:

I2C communication* I²C - Inter-Integrated Circuit – or –I squared C) Used for attaching low-speed peripherals to a motherboard, embedded system, cellphone, or other digital device Any number of masters and slaves can be connected Devices are addressed by a 7-bit address Fees are required to obtain I²C slave addresses allocated by NXP SCL – serial clock line SDA – serial data line Transfer rates from: 10 kbit/s (low-speed mode)  5-MHz (Ultra Fast-mode) *http://en.wikipedia.org/wiki/I%C2%B2C

I2C pins on the RPi GPIO Pin 3 Serial Data Line Pin 5 Serial Clock Line Pin 1 3.3V Pin 6 ground

To access I2C pins… You MAY need to edit the following files: sudo nano /etc/modprobe.d/raspi-blacklist.conf Add a # character before the i2c line and save: #blacklist i2c-bcm2708 sudo nano /etc/modules Add these lines at the end of the file and save: i2c-dev i2c-bcm2708

I2C Code to control HMC5883L /* This code reads data from a Honeywell HMC 5883L 3-axis compass whether it is a standalone breakout board or part of an IMU. Data is read via I2C communications indefinitely. There are only minor adaptations of this code from one that was found on an on-line discussion board. Wes Lawson 4/20/2014 Initial version */ #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <linux/i2c-dev.h> #include <math.h>

I2C Code to control HMC5883L const int HMC5883L_I2C_ADDR = 0x1E; void selectDevice(int fd, int addr, char * name) { if (ioctl(fd, I2C_SLAVE, addr) < 0) { fprintf(stderr, "%s not present\n", name); } } void writeToDevice(int fd, int reg, int val) char buf[2]; buf[0]=reg; buf[1]=val; if (write(fd, buf, 2) != 2) { fprintf(stderr, "Can't write to HMC5883L\n"); }

I2C Code to control HMC5883L int main(int argc, char **argv) { int fd; unsigned char buf[16]; if ((fd = open("/dev/i2c-1", O_RDWR)) < 0) // Open port for reading and writing fprintf(stderr, "Failed to open i2c bus\n"); return 1; } /* initialize HMC5883L*/ selectDevice(fd, HMC5883L_I2C_ADDR, "HMC5883L"); writeToDevice(fd, 0x01, 32); writeToDevice(fd, 0x02, 0);

I2C Code to control HMC5883L while(1) { buf[0] = 0x03; if ((write(fd, buf, 1)) != 1) { fprintf(stderr, "Error writing to i2c slave\n"); // Send the register to read from } if (read(fd, buf, 6) != 6) { fprintf(stderr, "Unable to read from HMC5883L\n"); } else { short x = (buf[0] << 8) | buf[1]; short y = (buf[4] << 8) | buf[5]; short z = (buf[2] << 8) | buf[3]; float angle = atan2(y, x) * 180 / M_PI; printf("x=%d, y=%d, z=%d\n", x, y, z); printf("angle = %0.1f\n\n", angle); } usleep(500 * 1000); // wait 1/2 second return 0;