Docsity

Countdown Timer - Microprocessor Laboratory 3 Report | ECE 332, Lab Reports of Microprocessors

Toggle sidebar
bg1
ECE 332L
Microprocessors Lab Lab 3
Spring 2008
Count Down Timer
Page 1 of 7
C:\ece332\labs\lab3\docs\lab3.doc
Objective: In this lab, you will develop a count down timer system. This system will interface to
switches, LEDs, buttons, and seven-segment LEDs.
Pre-Lab: Review the following before coming to lab next week (you should have already read this for
Lab 2).
Reading from N2PRH n2cpu_niiv1.pdf
Chapter 7. JTAG UART Core and Avalon Interface
Chapter 13. PIO Core
Reviewing this documentation and paying special attention to the Register Map section (page 13-7)
should provide additional insight into the operation of these devices.
Resources:
lab3.sof, lab3.ptf
Altera DE2 Development Board
Altera Debug Client (Quartus II Programmer)
Deliverables: Demonstration to lab instructor.
Formal report with complete project directory including readme.txt (zipped)
Email to: [email protected]
Date Due: Check off demonstration - 2/12/08
Report and project files – before midnight 2/15/08
pf3
pf4
pf5

Partial preview of the text

Download Countdown Timer - Microprocessor Laboratory 3 Report | ECE 332 and more Lab Reports Microprocessors in PDF only on Docsity!

Spring 2008 Count Down Timer

Page 1 of 7

Objective: In this lab, you will develop a count down timer system. This system will interface to

switches, LEDs, buttons, and seven-segment LEDs.

Pre-Lab: Review the following before coming to lab next week (you should have already read this for

Lab 2).

Reading from N2PRH n2cpu_niiv1.pdf

Chapter 7. JTAG UART Core and Avalon Interface

Chapter 13. PIO Core

Reviewing this documentation and paying special attention to the Register Map section (page 13-7)

should provide additional insight into the operation of these devices.

Resources :

lab3.sof, lab3.ptf

Altera DE2 Development Board

Altera Debug Client (Quartus II Programmer)

Deliverables: Demonstration to lab instructor.

Formal report with complete project directory including readme.txt (zipped)

Email to: [email protected]

Date Due: Check off demonstration - 2/12/

Report and project files – before midnight 2/15/

Spring 2008 Count Down Timer

Page 2 of 7

In this lab, you will develop a count down timer display system. This display system interfaces to

switches, LEDs, buttons, and seven-segment LEDs.

Note 1: key0 is processor’s reset.

Part 1: Requirements and System Description

This display system will take the value to be displayed from “Value Switches” (as shown in the

following figure) and display to one of the seven-segment LEDs. The position of the “Select Switches”

(SW2-SW0) decides which seven-segment LED digit will receive the number generated by “Value

Switches” (SW17-SW14). The process to upload the number (generated by “Value Switches”) is

controlled by a button as shown. A button push (KEY3) will upload the value to the designated seven-

segment LED (This will cause the value to stay at the selected position). The current value of the Select

switches should be displayed on LEDR3-LEDR0, the current value of Value Switches should be

displayed on LEDR17-LEDR14. KEY1 will be used to START/STOP the count down timer.

Value

Switches

SW17-SW

Select

Switches

SW2-SW

Button to

Latch Value

KEY

Button to

Start/Stop

Count down

KEY

Spring 2008 Count Down Timer

Page 4 of 7

C:\ ... \Lab3\app_software\dev\LEDG.s

C:\ ... \Lab3\app_software\dev\LEDR.s

C:\ ... \Lab3\app_software\dev\SEG7.s

C:\ ... \Lab3\app_software\dev\SWITCHES.s

C:\ ... \Lab3\app_software\include\system.inc

C:\ ... \Lab3\app_software\include\mymacros.inc

Following is how you will need to associate these files with the Altera Debug Client. (The path up to

Lab3 is of your choice) Make sure that lab3main.s is at the top of list.

Part 4: Getting Started

Following is a skeleton implementation for the top level of your project. It does not contain all of the

required functionality. Do not assume that this represents good documentation style. Code provided to

you is intentionally brief. When you use provided code you are required to provide documentation and

maintain or improve the coding style.

Spring 2008 Count Down Timer

Page 5 of 7

C:\ ... \Lab3\app_software\src\lab3main.s

.include "../include/system.inc" .include "../include/mymacros.inc" .text .global _start _start: br PROGRAM_START

.org 0x

PROGRAM_START:

movia r4,0x call SEG7_Set

loop: call get_index # SWITCHES.s mov r4,r mov r17,r call disp_index # LEDG.s

call get_newhex # SWITCHES.s mov r4,r mov r16,r call show_newhex # LEDR.s

call get_set # BUTTONS.s beq r2,r0,loop

mov r4,r mov r5,r call SEG7_Set_Digit # SEG7.s br loop loop_end: END: break br END .end

Note that parameters to function calls are passed via registers r4 and r5, and returned values are passed

back via register r2. Also note that at the top level we are not directly referencing any specific ports. By

putting all of the code to deal with a port into a separate device module, we are providing a level of

abstraction that allows us to more easily retarget code to another platform. Making calls directly between

device modules is generally not a good practice. As demonstrated in this top level module, queries for the

index setting are requested from the switches module and then passed to the green LEDs module. In

other words, no hidden backdoor functionality is performed for basic operations.

The general format for each of the device modules is to place all of the code to access individual devices

that share a common register port into one source file. In the case of input devices this is all that is

needed. For output ports a shadow port can be used to simulate reading the current state of the real port.

Following is pseudo code that shows how this works:

Spring 2008 Count Down Timer

Page 7 of 7

Part 5: Completing the Lab

Using the above templates, complete the code for LEDR.s, LEDG.s, SWITCHES.s, BUTTONS.s, and

SEG7.s.

You will need to decide how to implement the start/stop functionality to the preceding system.

More important than documentation is the choice of good function and variable names. The choices for

these examples should not be considered as the best names. Please take the liberty to improve upon the

names and add any style elements that make the code clearer to read and understand. The usage of

macros to help make the purpose clearer is desirable. Remember that the grader will like simpler code.

The requirement for conversion between decimal and hexadecimal display format will present some

challenging issues. You will need to make some executive decisions to handle some of these items. The

best solution is probably unreasonable to expect at this time. However, you are asked to make your best

attempt at resolving these issues and provide documentation in your write-up to detail your decision

process during design and implementation.