Embedded systems:
Report 2
Content
Resume of our final embedded system............................................................................................................... 3
Manual of use: ................................................................................................................................................. 3
XPS hardware development ................................................................................................................................ 4
The external 7 segment board ........................................................................................................................ 4
SDK Software Development ................................................................................................................................ 4
Disp.h and Disp.c ............................................................................................................................................. 5
Main................................................................................................................................................................. 7
Photos of the Embedded System Working.......................................................................................................... 9
Conclusions ........................................................................................................................................................ 10
2
Embeded Systems Laboratory 2 Report
Our system controls an external 4 digit 7-segment board which features a number displayed in it, which can
be controlled with the PC’s keyboard through the USB to UART driver.
The digits are displayed in hexadecimal format, stored in a 16-bit variable just like demanded. We have
implemented the on/off display mode as well as the show/hide left-side zeros mode, which can be changed
with a switch or with the PC’s keyboard through the terminal.
The display is driven with interrupts, and we have kept the LEDs blinking system, just because we have
inherited from the project in Lab 1b.
Figure 1. Development board with the external board implementing the 7 segment display attached
Manual of use:
We programmed it so that the displayed hexadecimal value can be changed using the “4” and “5” keys from
the keyboard.
The display on/off is done by the switches and the zeros on the left of the displayed number too.
3
Embeded Systems Laboratory 2 Report
We had to add new peripherals in order to control the 7 segment display. We decided to use two of them, one
called “digit_0” to alternate between each individual display and “set_segments_0” which has 8 outputs, 7 for
the display plus 1 for the decimal point. The combination of this two new peripherals will allow us to fully
control the 7 segment display.
We were required to create the needed C++ classes and implement them. In other to properly control the new
peripherals and in turn control the 7 segment display.
4
Embeded Systems Laboratory 2 Report
The “disp.h” file contains the CDisplay C++ class declaration. This file is included in the main file in order to
use the CDisplay C++ class and be able to control the 7 segment display.
5
Embeded Systems Laboratory 2 Report
In Figure 4 we can see the whole disp.cc file which contains the definition of the CDisplay C++ class that we
created to control the 7 segment display.
On the constructor function we set the base addresses of our I/O peripherals that control the 7 segment
display. We also initialize “Data” which is the variable containing the 16 bit number that we will display in
hexadecimal format through the 7 segment display. We also initialize “zeros” and “on” which will allow us to
display the left side zeros and turn on and off the display.
The “to7seg” function implements the truth table used to convert from the number to the 7 segment code.
We will have to do that for each digit, which in hexadecimal means for each 4 bits.
The table is implemented in a vector containing the correct combination of each single LED for each possible
number to display. We just pick the position corresponding to that value.
6
Embeded Systems Laboratory 2 Report
The function “Refresh” is the one called periodically and is interpreting the “zeros”, “on” and “Data”
information to display the correct value in the way chosen by the user. In this function first we decide,
depending on the size of our variable “Data” how many displays we’ll need to use from our four 7 segment
displays, we set “b” accordingly. Then we use b to shift bits (4 at a time) and rotate the display used. The high
speed rotation of the four 7 segment displays creates the persistence effect on our eyes and we see them all
powered on at the same time. In reality they are never turned on simultaneously.
Main
Figure 5. Includes, defines, global variables and function definitions in main.cc file
7
Embeded Systems Laboratory 2 Report
In Figure 5 the main difference we see from the laboratory 1b is that we have enhanced functionality in the
config_from_switch() function, consisting on checking the state of the now switches to decide whether to
turn on/off the 7 segment display and whether to show zeros on the left side of it or not.
In config_from_uart() function the enhanced functionality resides in having numbers 4 and 5 of the keyboard
to change the displayed value on the 7 segment display, -10 and +10 respectively.
In Figure 6 we can see that we didn’t change much regarding the ISRs and the actual “main()”, we just added
the “Display.Refresh” inside the timer interrupt service routine.
8
Embeded Systems Laboratory 2 Report
9
Embeded Systems Laboratory 2 Report
Conclusions
In this last laboratory we managed to independently choose and add a new peripheral to an already existing
system. On top of that we created from scratch the necessary code to implement the functionality that the
new peripheral added to our system.
FPGAs and the way we used them in this subject make for an exceptional development tool for embeded
systems.
10