Definitions and Documents



Similar documents
The I2C Bus. NXP Semiconductors: UM10204 I2C-bus specification and user manual HAW - Arduino 1

NB3H5150 I2C Programming Guide. I2C/SMBus Custom Configuration Application Note

Interface and Simulation of a LCD Text Display

MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence :

Serial port interface for microcontroller embedded into integrated power meter

AVR311: Using the TWI Module as I2C Slave. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Chapter 5 Real time clock by John Leung

AVR315: Using the TWI Module as I2C Master. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

Chapter 12. Development Tools for Microcontroller Applications

RS-485 Protocol Manual

Lab 2.0 Thermal Camera Interface

Project Manager Editor & Debugger

AN141 SMBUS COMMUNICATION FOR SMALL FORM FACTOR DEVICE FAMILIES. 1. Introduction. 2. Overview of the SMBus Specification. 2.1.

Chapter 13. PIC Family Microcontroller

Programing the Microprocessor in C Microprocessor System Design and Interfacing ECE 362

USB2.0 <=> I2C V4.4. Konverter Kabel und Box mit Galvanischetrennung

AN601 I2C 2.8 Communication Protocol. SM130 SM130 - Mini APPLICATION NOTE

Table 1: Address Table

Serial Communications

Next Generation Intelligent LCDs

Web Site: Forums: forums.parallax.com Sales: Technical:

Programming Flash Microcontrollers through the Controller Area Network (CAN) Interface

1. Computer System Structure and Components

USER GUIDE EDBG. Description

Microtronics technologies Mobile:

Hardware and Software Requirements

SKP16C62P Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.

Embedded Component Based Programming with DAVE 3

- 35mA Standby, mA Speaking pre-defined phrases with up to 1925 total characters.

EMBEDDED C USING CODEWARRIOR Getting Started Manual

Tutorial for MPLAB Starter Kit for PIC18F

Software based Finite State Machine (FSM) with general purpose processors

AN2824 Application note

I 2 C Master Mode Overview and Use of the PICmicro MSSP I 2 C Interface with a 24xx01x EEPROM

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

Training Document for Comprehensive Automation Solutions Totally Integrated Automation (T I A) MODULE A5 Programming the CPU 314C-2DP

Microcontrollers in Practice

Keil C51 Cross Compiler

PC Base Adapter Daughter Card UART GPIO. Figure 1. ToolStick Development Platform Block Diagram

Table 1 below is a complete list of MPTH commands with descriptions. Table 1 : MPTH Commands. Command Name Code Setting Value Description

Software User Guide UG-461

Trace Port Analysis for ARM7-ETM and ARM9-ETM Microprocessors

Chapter 2: OS Overview

AN1229. Class B Safety Software Library for PIC MCUs and dspic DSCs OVERVIEW OF THE IEC STANDARD INTRODUCTION

DsPIC HOW-TO GUIDE Creating & Debugging a Project in MPLAB

SRF08 Ultra sonic range finder Technical Specification

AN LPC1700 timer triggered memory to GPIO data transfer. Document information. LPC1700, GPIO, DMA, Timer0, Sleep Mode

EE8205: Embedded Computer System Electrical and Computer Engineering, Ryerson University. Multitasking ARM-Applications with uvision and RTX

Elettronica dei Sistemi Digitali Costantino Giaconia SERIAL I/O COMMON PROTOCOLS

Software development and debugging for NXP ARM7 MCUs

DS Wire Digital Thermometer and Thermostat

ARM Ltd 110 Fulbourn Road, Cambridge, CB1 9NJ, UK.

Using the HCS12 Serial Monitor on Wytec Dragon-12 boards. Using Motorola s HCS12 Serial Monitor on Wytec s Dragon-12 boards

Using DAVE with MDK Version 5

AN736. An I 2 C TM Network Protocol for Environmental Monitoring THE I 2 C BUS SPECIFICATION INTRODUCTION

1-Port R422/485 Serial PCIe Card

Microcontroller Systems. ELET 3232 Topic 8: Slot Machine Example

DS1621 Digital Thermometer and Thermostat

Serial Communications

Palaparthi.Jagadeesh Chand. Associate Professor in ECE Department, Nimra Institute of Science & Technology, Vijayawada, A.P.

AN1754 APPLICATION NOTE

ELEG3924 Microprocessor Ch.7 Programming In C

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

Eliminate Risk of Contention and Data Corruption in RS-485 Communications

Lab 1 Course Guideline and Review

Nuvoton Nu-Link Debug Adapter User Manual

Embedded Systems on ARM Cortex-M3 (4weeks/45hrs)

Internal Oscillator. I 2 C Interface. SPI Interface. Controller. Internal Registers Port Controller. Eight I/O Pins. Figure 1.

Programming the On-Chip Flash on a phycore-xc161 phycore-xc167

SPI I2C LIN Ethernet. u Today: Wired embedded networks. u Next lecture: CAN bus u Then: wireless embedded network

DALI Control Gear Software Stack

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

CENTRONICS interface and Parallel Printer Port LPT

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

IR Communication a learn.sparkfun.com tutorial

Embedded Software development Process and Tools:

Embedded Systems Design Course Applying the mbed microcontroller

An Introduction to MPLAB Integrated Development Environment

User s Manual of Board Microcontroller ET-MEGA2560-ADK ET-MEGA2560-ADK

MX PIC24F Educational Module User Manual

Atmel Norway XMEGA Introduction

Bluetooth Audio Data Transfer between Bluetooth chipset (PMB6752&PMB6625) and TriCore Host TC1920

UniPi technical documentation REV 1.1

How to design and implement firmware for embedded systems

DS1307ZN. 64 x 8 Serial Real-Time Clock

Dolphin In-Circuit programming Updating Firmware in the field

Microprocessor & Assembly Language

Using the CoreSight ITM for debug and testing in RTX applications

Ride7 for ARM. RAISONANCE Tools for the STRx and STM32 families. Overview and Getting Started

CGI-based applications for distributed embedded systems for monitoring temperature and humidity

Implementing a Digital Answering Machine with a High-Speed 8-Bit Microcontroller

AN3155 Application note

ZX-NUNCHUK (# )

Using HiTOP with the HOT16x Hands-On Training Materials

DS1621 Digital Thermometer and Thermostat

Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol

A L ERT. Quick Start With

LINDY ELECTRONICS LIMITED & LINDY-ELEKTRONIK GMBH - SECOND EDITION

8051 Flash Microcontroller. Application Note. A Digital Thermometer Using the Atmel AT89LP2052 Microcontroller

Transcription:

C Compiler Real-Time OS Simulator Training Evaluation Boards Using and Programming the I 2 C BUS Application Note 153 June 8, 2000, Munich, Germany by Keil Support, Keil Elektronik GmbH support.intl@keil.com ++49 89 456040-0 This Application Note describes programming of the I 2 C Bus for various devices. Included is the debugging and simulation of I 2 C Bus Applications with the Keil µvision2 Debugger/Simulator. Definitions and Documents The I 2 C Bus is a two-wire BUS system defined by Philips beginning of the 1980 s. The I2C Bus is a bidirectional and designed for simple but efficient control applications. It is widely used in embedded systems to interface a microcontroller with peripherals. The system is comprised of two lines, SCL (serial clock) and SDA (serial data) that carry information between the IC s connected to them. All devices connected to the bus can be master or slave devices. Each device can be in one of the following modes: Idle Mode: device is in high-impedance state and waits for data. Master Transmitter Mode: the device transmits data to a slave receiver. Master Receiver Mode: the device receives data from a slave transmitter. Slave Receiver Mode: a number of data bytes are received from a master transmitter. Slave Transmitter Mode: a number of data bytes are transmitted to a master receiver. The I 2 C standard is described in the I 2 C BUS SPECIFICATION that is available at the Philips web page or the Keil Development Tools CD-ROM in the folder Datashts\Philips. I 2 C Concepts This application note describes the implementation of the I 2 C bus on 8051, 251 and 166 based devices. The bus can be implemented in several different ways on a device. I 2 C serial port with hardware implemented Master and Slave functions (as in Philips 80C552, 558, ect and serveral AtmelWM devices) Combined SPI/I 2 C interface with hardware implemented Slave and software based Master functions (as in Analog Devices ADuC812, ADuC824 and several other devices). Single bit hardware for software based Master and Slave support (as in Philips 8xC75x and Philips LPC series, described in Philips AN422 available from the Philips Web page or the Keil Development Tools CD-ROM folder AppNotes\Philips). Using and Programming the I 2 C BUS Page 1 of 5

Using the High-Speed Serial Interface of the Infineon 166/ST10 family for simulation of the I2C bus. (Described in the Infineon AppNote AP1626 (RK has it)). Software based simulation of a I2C Bus Master device. This can be implemented in any 8051 or 166 device be using two un-used I/O pins as SCL and SDA pins. These I/O pins are controlled by software only. I 2 C Simulation For efficient software testing is it not enough just to simulate the behavior of the I2C bus at bit-level. Instead it must be possible to simulate also bus communication. Therefore µvision allows you: to review the bus activities and create data on the I 2 C bus in the I 2 C communication dialog. virtual simulation registers (VTREG) the can be used to review and enter data to the I 2 C bus. and write debug functions that simulate a device that is connected to the microcontroller. In this way you can simulate your complete application rather than just a small piece of the bus communication. I 2 C Dialog µvision2 offers an tabbed dialog that shows you on the first page the controls and status of the I 2 C interface and on the 2 nd page a communication (similar to the CAN communication page see AN147). I 2 C Hardware: this page allows you to review and modify the I 2 C settings trough hardware registers and to show the current I 2 C Interface status Using and Programming the I 2 C BUS Page 2 of 5

I 2 C Communication: this page allows you to review the data communication on the I 2 C bus and to directly enter data on the I 2 C bus using the Message Generator Virtual Simulation Registers (VTREG) The µvision2 Debugger implements virtual simulation registers (VTREG) that can be used to review the I 2 C communication on the Debugger command line level or within Debug and Signal functions. The following registers are implemented: VTREG Description I2C_IN I2C_OUT I2C_CLK Data sent from the I 2 C peripherals to the the Microcontroller: Possible values in this register are: 0xFFFF for IDLE or STOP condition 0x0100 for START, initiates SLAVE transmit or receive on the microcontroller; next byte is slave address 0x00.. 0xFF any address or data byte transfer to the microcontroller. 0xFF00 for ACK 0xFF01 for NACK Data sent from the Microcontroller to the I 2 C peripherals. Possible values in this register are: 0xFFFF for IDLE or STOP condition 0x0100 for START, initiates MASTER transmit or receive on the microcontroller; next byte is slave address 0x00.. 0xFF any address or data byte transfer to the I 2 C peripherals. 0xFF00 for ACK 0xFF01 for NACK Clock Frequency in Slave Mode in Hz, i.e. 100000 for 100KHz transmission µvision supports only the 8-bit address mode of the I2C bus. The 11-bit address modes are currently not implemented and also not supported by the most microcontroller devices. Using and Programming the I 2 C BUS Page 3 of 5

Simulating a Device connected to the I 2 C Bus With specific signal functions the user can implement hardware components that are connected to the I 2 C bus. The following example shows a signal function that simulates an I 2 C Memory (256 bytes) like the Philips PCF8570. The I 2 C Memory Slave address is set trough the SADR variable. Example: SADR = 0x3F // I 2 C Memory Slave Address The signal function is invoked from the command window as: I2Cmemory() The I 2 C Memory is mapped to the memory region V:0.. V:0xFF. Once the simulator detects a START condition in the I2C_OUT VTReg, the next byte will be interpreted as address byte. This address byte contains the 7-bit Slave address in bits 7.. 1 and in bit 0 the direction (0 = Write, 1 = Read). If the Slave Memory is addressed the Memory sends an ACK back to the Microcontroller. If the direction bit was 1 (Memory Read) the Microcontroller reads data bytes from the Memory (from the current address which is automatically incremented after each read byte) trough the I2C_IN VTReg. Microcontorller sends an ACK to the Memory after each byte if more data bytes should be read or an NACK if this is the last data byte read. If the direction bit was 0 (Memory Write) the Microcontroller sends first a byte with the new Memory address (Memory must return an ACK) and then sends data bytes which will be written to the Memory (to current address which is auto incremented after each written byte). Memory must return an ACK after each received byte. // Simulation of I2C Memory (Slave): like Philips PCF8570 (256 byte I 2 C RAM) MAP V:0,V:0xFF READ WRITE DEFINE int SADR // Map User Memory region // Slave Address signal void I2CMEMORY (void) { unsigned long adr; adr = V:0; while (I2C_OUT == 0x0100) { if (I2C_OUT > 0xFF) continue; if ((I2C_OUT >> 1)!= SADR) continue; if (I2C_OUT & 1) { I2C_IN = _RBYTE(adr); adr++; if (I2C_OUT!= 0xFF00) break; else { if (I2C_OUT > 0xFF) continue; adr = I2C_OUT V:0; if (I2C_OUT > 0xFF) break; _WBYTE (adr, I2C_OUT); adr++; // START detected // test if Slave is addressed // Slave Read // Read Byte from Memory // Increment Address // Wait for ACK from Microcontroller // Slave Write // Set Memory Address // Store Byte in Memory // Increment Address Using and Programming the I 2 C BUS Page 4 of 5

Application Examples I 2 C serial port with hardware implemented Master and Slave functions Enclosed is an example that shows you how to use the I 2 C bus with a Byte orientated Hardware. As example CPU we have used a Philips 8xC591 device. The µvision2 project I2CEEPROM includes a 591 I 2 C demonstration of reading and writing to a serial EEPROM (for the Phytec Development Board with 87C591 phycore module) and also the signal function that simulates an I 2 C EEPROM Memory (4k bytes). Single-bit Hardware for Software-Based Master and Slave support Enclosed is an example that shows you how to use the I 2 C bus with a Single Bit Hardware. As example CPU we have used a Philips LPC device. The µvision2 project Master includes I 2 C Single Master Routines for the 87LPC764 (taken from Philips AN422-8XC751 as I 2 C Bus Master) and also the signal function that simulates an I 2 C Memory (256 bytes). Using and Programming the I 2 C BUS Page 5 of 5