HOME
Lab components |
CSE
477: Embedded System Design
(Spring 2002) |
||||||||||
Lab
3:
Microcontrollers: Part III Timers and Interrupts Objectives: In this lab will you will learn the following:
Reading You will need to understand how to use the timers and interrupts and write interrupt routines. These are covered in the:
Part 1- Using the External Program Memory We are going to start using the external memory for programs instead of the ROM since we don't want to reimplement the FPGA every time we try a new program. Use the left memory bank for this purpose. You will need to wire the IROM bus to this memory instead of the ROM we were using before. This includes the address bus and the CE, WE and OE signals to the memory. To simulate with this external memory, you can still use the ROM solution that we used before, but when implementing the chip, you need to replace this with the external memory connection. The 8051 Lab page describes how to generate a file that can be downloaded into one of the RAMs on the XSV board. You first convert the HEX file to binary, and then download it to memory using a special bit file. After the program has been downloaded, you can download your project bit file. Try this out with the program you wrote for Lab 2.
Make a Keil project using the existing button.c file found in the \\ifilesrv1\courses\cse477\lab3 directory. This program displays a count on the the 7-segment display, 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. This interrupt is generated by a pin on the DW8051, which must be connected to one of the push buttons on the XSV-300 board. Compile and download this program to the XSV board using the external memory. Don't forget that you will need to wire one of the pushbuttons to the appropriate interrupt pin on the DW8051. The inter.c program in the lab3 folder demonstrates how to time the period of an external 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 of the DW8051.
The accelerometer we will give you measures acceleration along two orthogonal axes. It can be used to measure tilt in the X and Y dimensions by measuring the force of gravity in each dimension. The measured acceleration is given on two pins, one for each dimension, using a pulse width code as described in class and in the documentation. You should decide how to interface the accelerometer to the microcontroller so that the two acceleration values are available to a program running in the microcontroller. 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 two) 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. For example, you need to figure out how to re-zero the tilt-o-meter. This is a good time to play with the SFR's to customize our 8051. Choose some addresses that are not used and create the following registers:
Here is the interface
to the accelerometer:
|
|||||||||||
BACK
TO TOP
Last Updated:
|
Contact the instructor at:cse477-webmaster@u.washington.edu
|