

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


ELEC 2220 Computer Systems Homework # Due: Monday, 11-3-
In this exercise, you will practice with “program-controlled input/output”. As discussed in class, some devices provide a “ready” signal to indicate that some action should be taken (read a byte from the device, send a byte to the device, etc.) In this exercise, push-button 4, connected to Port T, will simulate such a signal. The “action” to be taken is to write a two-digit number to a seven- segment display.
A one-byte BCD number is to be created, and initialized to 00. The program is to continuously increment the BCD number once per second (00-01-02-…-98-99-00-01…) The one-second delay, which does not have to be exact, should be a simple “do nothing” loop. You should consider using the “decimal adjust” instruction, following an “adda #1” instruction for your BCD counter.
While the counting process is taking place, the program should periodically check the state of push-button 4. Any time the button is pressed, the current value of the BCD number should be displayed on the right-most two digits of a seven-segment LED display. Initially, the number 00 should be displayed. For example:
BCD count = 0 – 1 – 2 – 3 - button detected, display 3 - 4 – 5 – 6 – 7 – 8 - button detected, display 8 - 9 – 10 – 11 – 12 ….
Since two seven-segment digits must be used, you cannot simply leave one digit or the other “enabled”. You must switch between them. The LEDs have some “persistence”, but will quickly fade if not refreshed with the data to be displayed. Therefore, your program must periodically refresh the information, in addition to checking the input button.
As in the previous homework, a seven-segment LED display is to be connected to Ports A and B of the HCS12. Recall that the bits of Port A are to be connected to the seven LED “segments” (segments activation), with bit 0 of Port A activating LED segment “a”, bit 1 of Port A activating LED segment “b”, etc. (A logic 1 activates the LED segment.) Port B is to be connected to the “display selection” signals of the 8-digit display component. Forcing bit 0 of Port B to logic 1 causes the segments of the right-most digit to display the data from Port A, bit 1 of Port B selects the second digit from the right, etc.
NOTE: When assigning addresses in the component setup window for a display component, push button component, etc., enter the numeric address of the port to which the device is connected. DO NOT select “Port A”, “Port B”, etc. from the drop-down list. Those symbolic names have been pre-assigned by Code Warrior to other addresses.
The push buttons are again to be connected to the pins of Port T. Recall that this is set up by selecting a “Push Buttons” component from the Component menu. Right-click on the
component, click on “setup”, and enter the address of Port T in the box. This connects button 0 to bit 0 of Port T, button 1 to pin 1, etc.