CMPE 443 – EXPERIMENT #2

advertisement
Release date: 03/11/2011
CMPE 443 – EXPERIMENT #2
In your second assignment, you will extend the first assignment to take commands from a
user as input and display the requested outputs.
In the system, the DIP-switch will be used to give the commands and LEDs and (or) sevensegment LED displays will be used to display the requested outputs.
You will read 8–bit inputs for the filter from a memory location and get 8-bit outputs from
the filter. For displaying output of the mean filter, you have to use two seven-segment LED
displays and display a single byte with low nibble on one seven-segment LED display and
high nibble on the other one.
Note that on your boards have a seven-segment LED display (connected to PORTA) and a
DIP-switch (connected to PORTB) readily available (For details see the board schematic). In
order to display an 8-bit output, you are required to use an additional seven-segment LED
display.
Naming for the switches:
The switch which is connected to PB0 will be called SW0, the switch which is connected to
PB1 will be called SW1 and the switch which is connected to PB2 will be called SW2.
The operation of your program should be as follows:
1- SW0 controls the mean filter operation.
a. When SW0 is changed from 0 to 1 system will calculate the next mean value.
2- SW1 and SW2 controls the types of output displayed on the LEDs and (or) sevensegment LED displays.
a. When SW1 is 0, the last mean filter output will be displayed.
b. When SW1 is 1, the position of SW2 decides the output.
i. When SW2 is 0, the mean value will be compared to threshold 1, and
the result should be displayed on the seven segment as
1. G, if mean is greater than threshold 1
2. E, if mean is equal to threshold 1
3. L, if mean is less than threshold 1
ii. When SW2 is 1, the mean value will be compared to threshold 2, and
the result should be displayed on the seven segment as
1. G, if mean is greater than threshold 2
2. E, if mean is equal to threshold 2
3. L, if mean is less than threshold 2
Figure 1: The 7-segment chip: “nc” is No Connection, meaning that you must not connect
anything to that pin, “h” stands for the “.” on the display and the structure of one segment of
the display.
Seven-segment LED Display
A seven segment display consists of leds as shown in Figure 1. These leds can be organized
in one of two ways:
Common cathode: Cathodes of the leds are common. Anodes are free Figure 2. To
display a number on the display,
1. Apply 0 to cathode.
2. Apply 1 to the anodes of the leds that you want to lit up. For example if you want
to display 3, then the applied signal must be (a,b,c,d,e,f,g)=(1, 1, 1, 1, 0, 0, 1). A
detailed table of applied signals is shown in Figure 2.
Common anode: It is the dual of common cathode, i.e. cathodes of the leds are
common, cathodes are free and display a number on the display
1. Apply 1 to anode.
2. Apply 0 to the cathodes of the leds that you want to lit up. For example if you
want to display 3, then the applied signal must be (a,b,c,d,e,f,g)=(0, 0, 0, 0, 1,
1, 0).
This organization also determines the type of the seven-segment display, i.e. you can either
buy a common-cathode seven segment display or a common-anode seven segment display.
Since LED is the basic element of the seven segment display, resistors (typically 4.7k) have
to be connected to free ends so that immense current will not harm the relevant led.
Figure 2: The common cathode display and the patterns to lit up numbers on the common
cathode display.
DIP-Switches
Figure 3: A DIP-switch with 8-switches. See the ON letters on the switch and a sample
setting of switches on the DIP-switch.
A DIP-switch is a series of tiny switches built into circuit boards. The housing for the
switches, which has the same shape as a chip, is the DIP (Dual In-line Package). DIP
switches are always toggle switches, which mean they have two possible positions.
“on or off”. On the chip, you see numbers for the switches. Moreover, there is ON written on
the chip to show the “on” condition of the switch as shown in Figure 3.
(Instead of on and off, you may see the numbers 1and 0.).
While connecting DIP-switch to between VDD and GND, resistors (typically 4.7k) have to
be connected to either ON or OFF part of the switch so that immense current will not harm
the switch.
Constraints for the Implementation:
In your implementation, you should consider the following constraint:
1. How to read the source list and write to the target list is left as the design decision.
But you should consider that the inputs will be read from the memory and outputs will
be displayed to the user in the future.
2. The threshold values will remain same during a simulation run and the decision of
how to keep the threshold values is left as the design decision.
3. Calculation of the average should be in assembly and it should be called from a main
function of the code in C.
Report:
In your report, you should show your top-down modular design, explain your code
and give answers for the following questions:
1. What is the stopping criteria for your implementation?
2. What is the size of your code? (Minimum size will get maximum points.)
3. What is the execution speed of your code? (Note: examine for different lengths of
source lists and tap values.) (The most efficient implementation in terms of speed will
get maximum points.)
4. Is your code portable? (Is it possible to change source list, target list, and the order of
the filter (tap value) easily?)
5. Explain your assumptions and limitations of your code?
Note 1: Don't forget, smaller in size, faster and more portable code will get the maximum
grade.
Note 2: You should submit the WHOLE PROJECT FOLDER with the report.
Deadline: 16/11/2011 23:59
Download