Basic PIC-C I2C Communication

Slides:



Advertisements
Similar presentations
IO Interfaces and Bus Standards. Interface circuits Consists of the cktry required to connect an i/o device to a computer. On one side we have data bus.
Advertisements

Finite State Machine & PIC-C I2C Communication
Categories of I/O Devices
LOGO Lab Supervisor – Dr. WH Lau EE3271 Design Laboratory.
EXTERNAL COMMUNICATIONS DESIGNING AN EXTERNAL 3 BYTE INTERFACE Mark Neil - Microprocessor Course 1 External Memory & I/O.
Embedded Systems I2CI2C. Feature 3 wire GND SCL(clock) SDA(data) All devices share the same bus wire Using wire and, each device gain access to bus (become.
Serial Interfaces, Part Deux -I 2 C and SPI December 4, 2002 Presented by Eugene Ho.
Basic PIC-C I2C Communication and Controlling the 7-segment module Arnan (Roger) Sipitakiat Department of Computer Engineering, Chiang Mai University,
Lecture 8: Serial Interfaces
ME106 Sensor Presentation: WII Nunchuck Evan Ly, Marcus Solis 31OCT2012.
Serial Communication Buses: I 2 C and SPI By Brody Dunn.
EE 316 Computer Engineering Junior Lab Word Mastermind.
EE 316 Computer Engineering Junior Lab PS/2 Keyboard.
Technion-Israel Institute of Technology Electrical Engineering Department High Speed Digital Systems Laboratory Project subject: wireless biofeedback system.
HT46 A/D Type MCU Series Data Memory (Byte) Program Memory HT46R22 (OTP) HT46C22 (Mask) 2Kx Kx16 4Kx HT46R23 (OTP) HT46C23 (Mask) HT46R24.
Interfacing. This Week In DIG II  Basic communications terminology  Communications protocols  Microprocessor interfacing: I/O addressing  Port and.
I2CI2C CS-423 Dick Steflik. Inter-Integrated Circuit Developed and patented by Philips for connecting low speed peripherals to a motherboard, embedded.
EE 316 Computer Engineering Junior Lab Digital Hangman.
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
Technion-Israel Institute of Technology Electrical Engineering Department High Speed Digital Systems Laboratory Project subject: wireless biofeedback system.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 10: Serial buses Oct 6, 2011.
SERIAL BUS COMMUNICATION PROTOCOLS
1 © Unitec New Zealand I2C Lecture 10 Date: - 2 Nov, 2011 Embedded Hardware ETEC 6416.
Baseboard Aavikkomursu 7.2. Aavikkomursu Micro- controller Extension port for programming microcontroller and sensor input Resistor RS485 interface chip.
Lecture 111 Lecture 11: Lab 3 Overview, the ADV7183B Video Decoder and the I 2 C Bus ECE 412: Microcomputer Laboratory.
LSU 10/22/2004Serial I/O1 Programming Unit, Lecture 5.
Embedded Bus – i2c David E. Culler Lab 2 Feb 2, 2015
Ballooning Bundle. What is a Microcontroller? Small computer with a processor core, memory and programmable input/output Continuously repeats software.
4.0 rtos implementation part II
©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 13 Computer Systems Roger.
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.
1 SERIAL PORT INTERFACE FOR MICROCONTROLLER EMBEDDED INTO INTEGRATED POWER METER Mr. Borisav Jovanović, Prof.dr Predrag Petković, Prof.dr. Milunka Damnjanović,
 Project Description & Goals  Hardware Used  Circuitry & Connections  Communication  Software & Programming  End Result.
Lecture 20: Communications Lecturers: Professor John Devlin Mr Robert Ross.
DEVICES AND COMMUNICATION BUSES FOR DEVICES NETWORK
Arnan Sipitakiat Dept. Compute Engineering, Chiang Mai University.
Autonomous Helicopter James LydenEE 496Harris Okazaki.
PCA9557: REMOTE 8-BIT I 2 C AND SMBus LOW- POWER I/O EXPANDER.
I2C Master Core Simulation Environment. I2C Master Core Requirements Coverage (*) Requirement I2C IP RS-906: The I2C IP shall define the period of time,
Design of a Novel Bridge to Interface High Speed Image Sensors In Embedded Systems Tareq Hasan Khan ID: ECE, U of S Term Project (EE 800)
1 Synchronous Serial IO Send a separate clock line with data –SPI (serial peripheral interface) protocol –I 2 C (or I2C) protocol Encode a clock with data.
Chris Wallau ECE5330 November 17, 2008 Remote Thermometer and Display.
©2008 R. Gupta, UCSD COSMOS Summer 2008 Peripheral Interfaces Rajesh K. Gupta Computer Science and Engineering University of California, San Diego.
S4525A Peripherals & Enhanced FLASH 1 © 1999 Microchip Technology Incorporated. All Rights Reserved. S4525A Peripherals & Enhanced FLASH 1 Peripherals.
Essentials of Communication This simple model requires many guarantees. Sender Receiver Communication Link Data.
Department of Electronic & Electrical Engineering Serial interfaces Serial Interfaces allow communication between devices sending one bit at a time. In.
Serial Peripheral Interface SPI I2C (i-squared cee)
Readout of Temperature Monitor with SEABAS ’11 10/12 Y. Takubo (KEK) 1.
Embedded Communication Protocols Don Heer 10/18/10 1.
Microcontroller basics Embedded systems for mortals.
Department of Electrical Engineering, National Taiwan Ocean University I2C Bus 5/16/2013 Richard Kuo Assistant Professor.
1 of 20 How to use the Compass A. Compass. 2 Compass: - Provides heading relative to Magnetic North, not true North HMC5883L V input - I2C (not.
Module 8 Tutorial  An 8086 system is used for controlling the speed of a motor. The motor can operate at 5 different speeds (1- 5).  The speed.
میکرو کنترلرهای AVR Serial Interfaces, I2C and SPI
MICROCONTROLLER AND INTERFACING Presented by: Shefali Jethva ( ) Shivali Panchal ( ) Komal Soni ( ) Roll no. :- 14EC308.
UNIT 24 I2C Test 로봇 SW 교육원 조용수.
Serial Communication Buses: I2C and SPI
Inter-IC Bus (I C) 2.
Chapter 11: Inter-Integrated Circuit (I2C) Interface
(Inter-IC bus) By Tejaswini Gadicherla
Basic PIC-C I2C Communication
I2C PROTOCOL SPECIFICATION
Communication Lines Fundamentals.
BJ Furman ME 106 Fundamentals of Mechatronics 15NOV2012
I2C and RTC Chapter 18 Sepehr Naimi
Costas Foudas, Imperial College, Rm: 508, x47590
I/O Experiments Assignment 1.
Presentation transcript:

Basic PIC-C I2C Communication Arnan (Roger) Sipitakiat Department of Computer Engineering, Chiang Mai University, Thailand

I2C Basics I2C is a Bus. Serial is point-to-point Master and Slave pair Master must start the communication Slave can only respond Slave has a 8-bit address Bit 0 is reserved for direction control

Basic I2C Bus Setup SDA SCL MASTER SLAVE 1 SLAVE 2 5V Pull-up Resistors SDA SCL

i2C Commands in PIC-C Master Only Slave Only Master & Slave I2c_start() I2c_stop() Slave Only I2c_isr_state() Master & Slave I2c_read() I2c_write()

Sending 1 Byte to Slave MASTER SLAVE I2c_start() I2c_write(slave addr | 0) I2c_write(registerAddress) I2c_write(value) I2c_stop() Address Content 1 2 3 4 5 6 7

Reading 2 bytes from slave MASTER SLAVE I2c_start() I2c_write(slave addr | 0) I2c_write(registerAddress) I2c_write(slave addr | 1) Value1 = I2c_read() Value2 = I2c_read(0) I2c_stop() Address Content 1 2 3 4 5 6 7

Write ค่า 50 ไปยัง Register 5 ของ slave ที่มี address = 100 I2c_start(); I2c_write(100 | 0); I2c_write(5); I2c_write(50); I2c_stop();

Write ค่า 1000 ไปยัง Register 5 (ไบท์บน), 6 (ไบท์ล่าง) ของ slave ที่มี address = 100 I2c_start(); I2c_write(100 |0); I2c_write(5); I2c_write(1000 >> 8); // upper byte of 1000 I2c_write(1000 & 0xFF); // lower byte of 1000 I2c_stop();

Read ค่าจาก Register 5 ของ slave ที่มี address = 100 Int returnValue; I2c_start(); i2c_write(100 |0); I2c_write(5); I2c_write(100 | 1); returnValue = i2c_read(0); I2c_stop();

Read ค่าเซ็นเซอร์ 2 byte จาก Register 5,6 ของ slave ที่มี address = 100 Int v1,v2; I2c_start(); i2c_write(100 |0); I2c_write(5); I2c_write(100 | 1); v1 = i2c_read(); V2 = i2c_read(0); I2c_stop();

Example I Controlling the Display Module Address = 0xB0 Register Address Function 2 High Byte 3 Low Byte

Example Program // i2c1 - Master #use i2c(MASTER, I2C1) // Show the number 100 on the screen I2c_start(); I2c_write(0xB0 | 0); // display module address I2c_write(2); // show number command I2c_write(0); I2c_wirte(100); I2c_stop();

Example II Reading from the ultrasonic sensor

How the module works

Direct Connection to the module You need to do all the timing yourself Implement timing

Let an I2C host perform the timing Offload to an I2C Host Let an I2C host perform the timing Take care of timing I2C

Tradeoffs of offloading The Good The sensor is simpler to use. The main processor is free to do other things. More modular. The Bad More expensive Must be careful of timing problems on the I2C host

Example 3: I2C devices on the market Digital Clock Barometer Temperature & RH Color Sensor Accelerometer Motor Driver

Motor Driver Module Register Address Function 0x82 Speed (0-255) 0x84 PWM Frequency 0xAA Direction (0/1) 0xA1 Select Motor A (0/1) 0xA5 Select Motor B (0/1)

Clock Module Module address = 0xD0