HOME
Lab components |
CSE
477: Embedded System Design
(Spring 1999) |
|||||||||||
Lab
2:
Microcontrollers: Timers and Interrupts Objectives: In this lab will you will learn the following:
Reading
Other
Relevant Links
Part
1-- External Interrupt Example
Make a Keil project using the existing button.c found in the \\ifilesrv1\cse477\lab2 directory. This program is the one from Lab 1 which lights up the segment in order, but an interrupt routine has been added that lights up all the LEDs on the digit display when the button is pressed. The trigger for this interrupt routine comes from an external interrupt pin. Here is a diagram that shows how to connect a switch to the pin to trigger the interrupt:
You should now change this program:
The inter.c file demonstrates how to time the period of a clock signal (this clock is the oscillator that is found in the lab kits). In summary, one interrupt routine keeps track of elapsed time and the other interrupt routine counts 10 cycles of the clock. The 7-segment display is changed every 10 cycles to show the current clock frequency. What code is used to display this frequency? Make a Keil project
with the inter.c file. Attach the clock generator probe from your Lab Kit
to the appropriate pin.
Part 3 -- Design
an interface to the Accelerometer.
Now write a program that uses the 7-segment display to implement an electronic level that shows the tilt of the accelerometer. Light up a segment (or 2) to show in which direction the accelerometer is tilted. If there is no tilt, light up the center segment. For extra credit, flash the lights to indicate the degree of tilt. Think about the user interface when designing this part. Use the information
and programs from previous parts to get started. The accelerometer works
in a simple way. There are is output for the x and y direction (one pin
x, one pin y). When the duty cycle of the output pin is about 50%, then
the accelerometer is level in that direction. If the duty cycle is bigger
or smaller than 50%, the accelerometer is tilted to one side or the other
in that direction. The resistor added to the accelerometer determines the
period of the output. The 1.2 Mohm gives a 10 ms period.
Here is the interface
to the accelerometer:
What
to Turnin
|
||||||||||||
BACK
TO TOP
Last Updated:
|
Contact the instructor at:cse477-webmaster@u.washington.edu
|