Upload
cale
View
22
Download
1
Embed Size (px)
DESCRIPTION
Example project for embedded firmware driver development on ARM PXA270 microcontroller.
Citation preview
1
CREATING AN I2C DRIVER FOR AN LM75 TEMPERATURE SENSOR
ECE 372 DESIGN PROJECT
WINTER 2013
Copyright
Douglas V. Hall
February 2013
BACKGROUND INFORMATION
The 2-wire I
2C serial bus is being used for an increasing number of devices and systems. It is currently used
with A/D converters, D/A converters, serial EEPROMs, range finders, temperature sensor modules, electronic
compass modules, GPS modules, touch-screen controllers, port expanders, Real Time Clocks, and many others.
Therefore, an understanding of the I2C protocol and some experience working with it are good skills to have in your
“toolbox”. Instead of having you work with the I2C Rangefinder described in the Hall text, you will in this exercise
work with an LM75 Temperature Sensor that is accessed through an I2C bus on the Zeus board.
Your first task for this exercise will be to create a low level driver program that uses the PXA270’s I2C
controller to read the current temperature value from the LM75 and put the value in a register each time the button
on the interface board is pressed. (You could send it to the talker using a small addition to your code from ECE 372
Design Project #1.) You will also change the High Temperature value to a value low enough that it will generate an
interrupt signal when you heat up the temperature sensor with your thumb.
LEARNING OBJECTIVES
This project pulls together some of the concepts from the previous projects and adds working with an I
2C
serial bus. At the conclusion of this design project you should be able to:
1. Convince yourself that the “Fast-is-Slow” approach to design really works.
2. Describe in detail the operation and use of the I2C bus.
3. Use a device data sheet to determine the series of address, command and data bytes that need to be sent
to or read from a specified I2C device for the desired operation(s).
4. Initialize and use a PXA270 I2C Controller for communicating with a specified device on an I
2C bus.
5. Devise an experiment to determine needed values not provided in a data sheet
6. Gain more experience with interrupts and GPIO pins.
BASIC SPECIFICATIONS FOR THE DESIGN
1. Your first program will initialize the I
2C controller as needed to read the current temperature value from the
LM75 Temperature Sensor each time the button on the interface board is pressed and put the value in a
register where it can be observed in Insight. (With very little work, you can also modify your talker
program slightly and add it to this program to speak the current temperature but this is not required.)
2. Your second program will initialize the LM 75 Overtemp value to 30 degrees Celsius and the Hysteresis
value to 28 degrees Celsius. Then, on an interrupt basis, the program will light the red LED on the interface
board when the OS signal is asserted on GPIO 96 by heating up the LM 75 with your thumb and turn the
LED off when the temperature drops below a hysteresis value.
REFERENCES
Hall Chapter 7 discussion of serial buses, the I
2C bus, and I
2C bus driver example program.
Hall Chapter 5 discussion of interrupt procedures.
LM 75 data sheet as found with Google search for LM 75 data sheet.” Note: may sources of data sheets.
Had you search to see how many. Some cost money, however, so best go to manufacturer, if available
there. LM is a National Semiconductor prefix but TI also makes device.
Intel PXA270 Developer’s Manual, Chapter 9, I2C Controller. (on PSU P: drive under armdocs)
2
PROCEDURE
NOTE 1: In previous projects, you were given a detailed sequence of development steps. A major point of this
exercise is to give you more practice in developing your own logical sequence of development steps instead of just
“hacking” your way through the project. The guiding principle is “Think before you act.” Your approach to solving
the problem will be evaluated as part of the grade for the exercise. Remember that you MUST do all work by
yourself with no help from anyone except the Instructor and the TA. Please do NOT contact companies for
assistance. You are not a paying customer and therefore not entitled to ask them to solve your problems. The
references and your previous design projects give more than enough information to successfully complete the
project.
NOTE 2: YOU MUST KEEP AN AS-YOU-GO LOG OF YOUR RESEARCH NOTES, YOUR
DEVELOPMENT PLAN, THE ACTUAL STEPS YOU TOOK, YOUR FINDINGS AT EACH
STEP, PROBLEMS ENCOUNTERED, HOW YOU SOLVED THESE PROBLEMS, AND, OF
COURSE, THE FINAL RESULT WITH APPROPRIATE DOCUMENTATION. THE TA OR I
WILL PERIODICALLY STOP BY AND ASK TO SEE YOUR LOG WHILE YOU ARE
WORKING, SO WE CAN OFFER SUGGESTIONS, RATHER THAN JUST GRADING IT AT
THE END. HERE ARE SOME GENERAL STEPS AND HINTS TO HELP YOU GET STARTED.
1. Read the background information on the I2C bus in Hall Chapter 7 to get an overview of how commands
and data are written/read on an I2C bus. Summarize your main findings in your log.
2. Thoroughly study the description of the PXA270 I2C controller and work through the Rangefinder program
in the text until you clearly understand how addresses and commands are sent on an I2C bus and how data
is read from a slave on an I2C bus using the PXA 270 I
2C controller.
3. Download and read the LM 75 data sheet. Read carefully through the entire data sheet to get a good
overview of the factors that must be considered when designing one of these devices into a product.
4. Read the LM 75 data sheet again to determine the internal addresses and how the internal registers are
accessed. Pay particular attention to the waveform examples to see the sequence of commands and
acknowledges that are required for a particular communication. Note that the I2C base address for the LM
75 on the Zeus board is 0x48.
5. Follow the general development procedure given in the I2C section of Hall Chapter 7 to develop and write
down the overall algorithm and detailed sequence of actions to read the temperature from the device.
Modify the basic button service procedure from one of your previous programs so that a new temperature is
read each time the button is pressed and to this add the assembly language instructions needed to tell the
PXA 270 I2C controller to read the temperature from the LM75.
6. This program should display the current temperature in an assigned register when the button is pushed.
7. To further test this version of the program as it runs, discharge any static electricity on your body by
touching a ground point and then hold your thumb on the Temperature controller IC. The LM75 IC is U11
in about the center of the Zeus board.
8. When the program works correctly, demonstrate it to the TA or Instructor, and have him sign it off on the
final version of the source file. Note that you must be able to answer TA questions about how your program
works in order to get it signed off.
7. For the second version of the program, you simply add: instructions that use the PXA 270 I2C controller to
set the TOS value to 32 degrees Celsius and the THYS Temp to 30 degrees Celsius; and an interrupt
procedure that responds to an interrupt signal from the OS output of the LM 75, lights the red LED on the
interface board when the temperature is above the OS value, and turns the LED off when the temperature is
below the THYST value. Note that according to page 2 of the Zeus board schematic that you have, the OS
(OVERTEMP) output of the LM 75 on the Zeus board is connected to the GPIO96 input of the PXA 270
processor. The only problem is that the Zeus board technical manual does not indicate which Alternate
Function of GPIO96 is used. Therefore, you will have to experiment a little and try different Alternate
Input Functions for GPIO 96 until you find the one that works. This experimentation step is intentionally
included in the exercise. On the job you often have to do some experimentation to get an optimum system
or because a data sheet is incomplete.
3
8. To test this version of the program, run it and then, after discharging any static electricity by touching a
ground point, hold your thumb on the LM75 to warm it up to a temperature past the OS setpoint.
9. When the program works correctly and turns the red LED on and off correctly with the thumb test,
demonstrate it to the TA or Instructor, and have him sign it off on the final version of the source file. (You
may have to adjust the TOS and THYST values to get this to work, depending on the room temperature and
your thumb temperature. Note that you must be able to answer TA questions about how your program
works in order to get it signed off.
DELIVERABLES
Your documentation for the project should include:
A. A detailed design log that shows the data you used, the steps and thinking you took to develop
the program, the results at each step, problems you encountered, and how you systematically
solved these problems.
B. A clearly written algorithm/detailed step sequence for each version of the program.
C. Printouts of the .S files for the two versions of your program with full comments. Printouts of
the final program versions must be signed by the TA or the Instructor to verify that your
program meets specifications and that you understand how the program works.
D. Labeled Screen printout of register contents showing your basic temperature read program
works.
E. A signed statement that you developed and wrote this program by yourself with no help
from anyone except the instructor and/or the T.A. and that you did not provide any help
to anyone else. (Any evidence of joint work will result in project grades of zeros for all
parties involved.)