Download Using I2C on an NXP Microcontroller
Transcript
Abstract This report walks through the implementation of the protocol on a microcontroller with the purpose of establishing communication with a color sensor. The basics of communication are presented. Details of necessary to the communication with the color sensor are provided in full. This report provides register-level detail on the steps necessary to drive an NXP controller as a master in order to communicate with a color sensor acting as a slave on an bus. Processing results from the color sensor is additionally discussed. Table of Contents Abstract .................................................................................................................................................. 1 Table of Contents .................................................................................................................................... 1 Introduction ............................................................................................................................................ 3 Motivation of Report ........................................................................................................................... 3 Hardware Used and Implied Limitations .............................................................................................. 3 Physical Design and Intent of Color Sensor Use .................................................................................... 3 Background ............................................................................................................................................. 4 I2C Communication Protocol ................................................................................................................ 4 General Description ......................................................................................................................... 4 Physical Description ......................................................................................................................... 4 Device Operation: Master or Slave ................................................................................................... 5 Operating Modes ............................................................................................................................. 5 Slave Device Addressing................................................................................................................... 5 Physical Layer Protocol Description.................................................................................................. 6 Software Layer Protocol Description: Writing Data to Slave ............................................................. 7 Software Layer Protocol Description: Reading Data from a Slave ..................................................... 8 I2C Debugging, Errors and Problem Resolution ................................................................................. 9 Color Sensor Gain Adjustment ............................................................................................................. 9 Capacitors........................................................................................................................................ 9 Integration Time .............................................................................................................................. 9 When is Gain Adjustment Necessary? ............................................................................................ 10 Methods and Results ............................................................................................................................. 10 1