代写辅导接单-ELEC5620M

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top

School of Electronic

& Electrical Engineering

FACULTY OF ENGINEERING & PHYSICAL SCIENCES

ELEC5620M: Embedded Systems Design

Assignment 1: Seven Segment

Display Driver

Dr David Cowell

Prof Steven Freear

Dr Thomas Carpenter

Dr Harry Clegg

Compiled with LuaT E X, last updated 14:56, on 24th February, 2024

ELEC5620M: Embedded Systems Design Assignment 1: Seven Segment Display Driver

Typographical conventions

The following typographical conventions are consistent throughout this module.

• Source code is shown in syntax highlighted monospaced font as:

a = !b;

• Hyperlinks to other documents, websites or downloads:

University of Leeds: Minerva Website

• Buttons, menus and file-tree selections you should click are shown as:

File » Exit

• Graphic User Interface (GUI) selections and text input are shown in italics:

Select Go from the list

Type Hello in the box.

• Keyboard shortcuts are shown in square brackets as:

[ctrl + C]

• Names of physical things are shown as bold font:

Cyclone V

• Names of commands and processes are shown as bold monospaced font:

commit

• File and project names are shown in bold green monospaced font:

hello.v

new_project

• Paths are shown as bold green monospaced using the Windows path separator \ :

C:\Path\To\File

Note: Extra information and clarification that you might find useful can be found in note blocks.

Warning: Potential pitfalls and problems are highlighted in warning blocks.

Important: Important information is shown in important blocks.

1

ELEC5620M: Embedded Systems Design Assignment 1: Seven Segment Display Driver

Part 1: Seven Segment Display Driver

Part 1: Seven Segment Display Driver

Now that you have been introduced to Arm Development Studio, your first assignment is a guided design

exercise to allow you to try out creating a driver for the DE1-SoC seven-segment display bank.

Partially-completed code is provided for you as a GitHub Classroom Assignment. The name of the as-

signment is ELEC5620M-Assignment1. You will need to accept this assignment (the link can be found on

Minerva) and clone this repository using GitHub Desktop in the same way as you did the source code for

the unit notes tasks.

This assignment is worth 30% of the final module mark. A full marking rubric is made available on Min-

erva and should be used to guide your work and submission during this assessment. The following is a

breakdown of the assignment marks:

• Code (30%)

• Debugging and Hardware Testing (30%)

• GitHub Version Control and Documentation (15%)

• Written Report (25%)

This assignment assesses your use of GitHub for code version control and online documentation, for ex-

ample the readme file. All code MUST be committed to GitHub from GitHub Desktop (or equivalent). Do

NOT upload code to GitHub from the web browser.

The report has a strict page limit of 2 technical pages and is intended as an executive summary describing

your functional coding and verification strategy plus the outcome of the design task. A 10% penalty will be

incurred for each additional page over the limit. You MUST additionally include a cover page with the

Assignment Title, your Name, University SID and email plus your GitHub username. The cover page does

not count towards the page limit.

ALL of your source code MUST also be included, as neatly formatted text in the Appendix (which will not

count towards the page limit). Screenshots or photos of code are NOT allowed and will NOT be marked!

You may additionally place supplementary diagrams and images in an Appendix, which will NOT count

towards the page limit.

Important: This assignment is due at 2pm on Monday 11th March 2024.

You must submit your report via Turnitin and Code via GitHub before the deadline. A 5% per day/partial

day penalty will be subtracted from your score for late submission.

If you encounter technical difficulties during submission, you MUST email your report and code to

[email protected] before the deadline and then submit/commit the report and code without

alteration through Minerva and GitHub respectively.

2

ELEC5620M: Embedded Systems Design Assignment 1: Seven Segment Display Driver

Part 1: Seven Segment Display Driver

1.1 7-Segment Displays on the LSC

You will probably have noticed there is a bank of 6 seven-segment displays on the DE1-SoC, labelled HEX5

- HEX0 (leftmost to rightmost) on the PCB. The task is to implement a driver library so you can control these

displays in the larger projects that you will develop later.

It is often the case that you will want to use the seven segment displays individually. However, as you might

be able to tell from the board layout, the seven-segment displays are arranged in pairs. This is convenient

as there are many reasons why it might be desirable to control two seven segment displays as one, so that

you can count values larger than 0 to 9 (or 0x0 to 0xF in hexadecimal). An example application which uses

this behaviour is a digital clock, where each of the hour, minute and second display pairs require maximum

values of 23, 59 and 59 respectively, all of which are greater than 9.

Within the Leeds SoC Computer (LSC), the seven segment displays are controlled using a pair of parallel

I/O ports as shown in Table 1.1. Each of the displays is assigned to its own byte, making use of the lower

7-bits to control the seven segments. The bit corresponding to each LED segment is shown in the image in

Figure 1.1. Bit-0 of each byte controls the top bar of the display, then bit-1 controls the top right bar, and so

on. In the LSC, writing a value of 1 to any bit will turn the corresponding LED on. For example, to display

the digit one, you would illuminate LED segments 1 and 2 by writing a 3 to the corresponding byte of the

base address for the 7 segment module you wish to control. The required layouts for the numbers 0-9 and

letters A-F are shown in Figure 1.2.

Address 31 30 ... 24 23 22 ... 16 15 14 ... 8 7 6 ... 0

0xFF200020 X HEX36−0 X HEX26−0 X HEX16−0 X HEX06−0 Displays 3-0

0xFF200030 X X X X X HEX56−0 X HEX46−0 Displays 4 & 5

Table 1.1: Parallel I/O Port Control Registers for the 7-Segment Displays

Figure 1.1: 7-segment LED bit mapping

Figure 1.2: 7-segment Symbol Layouts

3

ELEC5620M: Embedded Systems Design Assignment 1: Seven Segment Display Driver

Part 1: Seven Segment Display Driver

1.2 The main() Function

The key to this project is that the test program that demonstrates the functionality of the driver is already writ-

ten for you. The main() function, located in the main.c file, contains a program which uses the DE1-SoC

buttons to control the values set on the seven segment displays. A small helper function, getPressedKeys(),

tests to determine which (if any) of the four push buttons KEY0 - KEY3 have been pressed AND then re-

leased.

The main() function control program works as described below. Anything not described below is separate

from the control program, and is part of the seven segment display driver you will create.

Every while(1) loop,

• The program determines if any keys have been pressed and released.

• If KEY0 was pressed and released, the variable which sets the value on HEX0 increments by 1.

• If KEY1 was pressed and released, the variable which sets the value on HEX3-HEX2 increments by 1.

• If KEY2 was pressed and released, the variable which sets the value on HEX5-HEX4 increments by 1.

• If KEY3 was pressed and released, the variables which control each of the above displays resets to 0.

• Display HEX1 is not used in this project.

• After changing any of the variables above, the relevant display driver function is called to update the

display to the value stored in the variable.

• The watchdog timer is reset, so the HPS knows the program has not stalled.

You can see this behaviour if you open and read the main.c file.

You should not change the behaviour of the main function in this project at all. It is supposed to

be code which we have given to you to allow you to easily test the functionality of your driver. Once you

have created and configured the C project, the code should compile and will run even though you have not

completed any implementation work yet. The same is true as you go through the process of implementing

each function one-by-one — for the functions you have not implemented yet, simply nothing will happen.

1.3 The Library Interface

Because the test program is already written, we can imply that the interface to the display driver functions

is already defined. In this case, the interface is the name and argument signature of the functions that

comprise the seven segment display driver. The interface of C libraries is normally defined in header ( .h )

files, and in this assignment, that is the case. The DE1SoC_SevenSeg\DE1SoC_SevenSeg.h file defines

how the user (and in this case, the test program) should interface with the library. It is important that you

do not change how the driver functions are called in this project.

Important: You MUST NOT modify the main.c or DE1SoC_SevenSeg\DE1SoC_SevenSeg.h files.

4

ELEC5620M: Embedded Systems Design Assignment 1: Seven Segment Display Driver

Part 1: Seven Segment Display Driver

1.4 Assignment Guide

Follow each of the steps in this guide in turn. After you complete each step, you should commit your

work in GitHub Desktop with a meaningful commit message and description.

Note: Feel free to make extra commits as you try out new ideas or fix bugs. Smaller commits with

single, easy to describe changes are more useful than large commits when you want to refer back to

previous work or see what changed easily.

We recommend that you test and debug your solution thoroughly after completing each step.

Step 1 – Create your assignment repository using the link on Minerva

Step 2 – Create the project in Arm Development Studio

The Project Name is 1-A-SevenSegDisplay and the Location should be

C:\Users\<username>\Workspace\ELEC5620-Assignment1-<GitHubUsername>\1-A-SevenSegDisplay.

Step 3 – Configure the Project Settings

Use the Unit 1.1 notes to configure the project settings. The project will not compile until you have configured

the settings correctly.

Step 4 – Setting the Base Peripheral Addresses

The 6 seven-segment displays are split over two peripheral addresses, one for HEX0, HEX1, HEX2 and HEX3

and another for HEX4 and HEX5 as is shown in Table 1.1. The first thing you should do is set the base

peripheral addresses at the top of DE1SoC_SevenSeg.c.

Note: You might find it useful to declare the addresses with type volatile unsigned char*

, as each

of the seven segment displays use 8 bits of the address, and char is an 8-bit type. This will allow you

to easily address each of the seven-segment displays later.

5

ELEC5620M: Embedded Systems Design Assignment 1: Seven Segment Display Driver

Part 1: Seven Segment Display Driver

Step 5 – DE1SoC_SevenSeg_SetSingle()– Hexadecimal Single Display Decoder

The prototype of the function is listed in Listing 1.1.

38: void DE1SoC_SevenSeg_SetSingle(unsigned int display, unsigned int value);

Listing 1.1: Single Display Set function prototype ( DE1SoC_SevenSeg.h )

• For values 0-9 and A-F, work out which bits need to be set to illuminate the correct sections of the

seven segment display, so that the number is shown on the display. Refer to Figure 1.1 for the bit

to segment mapping, and Figure 1.2 to figure out which segments are needed for each symbol. For

example, if 1 is passed in, bits 1 and 2 are high, or if 0xC is passed in, bits 0, 3, 4, and 5 should be set

high.

• Write the function, where you first translate unsigned int value to the relevant bit-mapping value,

and call DE1SoC_SevenSeg_Write() with this value. If a value that is out of range is passed in, i.e.

greater than 0xF (16 or higher), you should set the display to show a dash (segment 6 only).

• It is possible to test this feature by pressing the button KEY0. This button has been configured in the

control program to increment the value of HEX0 every time you press it. Press the button enough times

to move from 0-9 then A-F. After you pass F, the display should just show a dash. You can press KEY3

to reset the value to 0.

Step 6 – DE1SoC_SevenSeg_SetDoubleHex()– Hexadecimal Dual Display Decoder

The prototype of the function is listed in Listing 1.2.

49: void DE1SoC_SevenSeg_SetDoubleHex(unsigned int display, unsigned int value);

Listing 1.2: Double Display (hexadecimal decoding) Set function prototype ( DE1SoC_SevenSeg.h )

• This function should take an input number in the range 0x00 - 0xFF and display it on a pair of dis-

plays. Use the display given in unsigned int displayfor the lower digit and display+1for the higher

digit.

• Out of range inputs should show a dash on both displays.

• This function will need to call DE1SoC_SevenSeg_SetSingle() twice.

6

ELEC5620M: Embedded Systems Design Assignment 1: Seven Segment Display Driver

Part 1: Seven Segment Display Driver

Step 7 – DE1SoC_SevenSeg_SetDoubleDec()– Decimal Dual Display Decoder

The prototype of the function is listed in Listing 1.3.

60: void DE1SoC_SevenSeg_SetDoubleDec(unsigned int display, unsigned int value);

Listing 1.3: Double Display (decimal decoding) Set function prototype ( DE1SoC_SevenSeg.h )

• This function should take an input number in the range 0 - 99 and display it on a pair of displays.

Use the display given in unsigned int display for the lower digit and display+1 for the higher digit.

• If a value of 9 is passed in, the next value should be 10, 1 on the first display, 0 on the second,

NOT a value of A.

• Out of range inputs should show a dash on both displays.

• This function will need to call DE1SoC_SevenSeg_SetSingle() twice.

• Hint: you may want to investigate the C modulo (%) operator.

END OF ASSIGNMENT BRIEF.

7

 

51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468