ECEN3000/3360 - Digital Design Lab
Lab 1: Introduction to the LPCXpresso Code Red IDE and the Arm
2 lab periods
This lab assignment is to get you familiar with the development
tools you'll be using this semester. This is the LPCXpresso
LPC1114 development board with the Arm Cortex M0 32-bit
Figure 1. The
LPCXpresso LPC1114 board.
The goal of this laboratory exercise is to have your very first
embedded software project successfully run on real embedded
hardware. To avoid watering down the experience, we will be
starting from scratch, and doing all of the work by
ourselves. This means that to begin, we must install
software! This includes the integrated development
environments (IDEs), software development kits (SDKs), and
reference source code. After it all works together, we'll
change some code to get an effect we like. If we can do
that, then we have set a foundation for making an embedded device
control or do anything we would like it to do!
Part 1 (Install Code Red)
- Download and install Code
Red, LPCXpresso's Eclipse-based IDE on either a lab
machine's h: drive, or on your personal laptop (since you will
be most likely be needing outside of classroom time to work with
this IDE, we highly encourage you to install Code Red on your
own laptop). You will need to register an account in order
to do so, please use any email address for the registration that
you wish. For groups of two students, both will need to
create their own accounts.
- Please read and follow LPCXpresso's tutorial
for the above procedure (doing so will speed your progress
Part 2 (The "Blinky" example)
- Download the NXP-provided Arm Cortex M0 example
projects and copy into the workspace directory for your
installation of Code Red. Written in the C language, these
provide you with great starting points for how to use of many of
the M0's peripheral subsystems in your own custom projects.
- Launch Code Red and build the "Blinky" example project by
hi-lighting it first and then going to Project->Build
- After a successful build, you are now ready to run the Blinky
project on the board itself. With the Blinky project still
hi-lighted and the LPCXpresso board connected, go to the button
on the top toolbar that is patterned after a green bug (looks
like a beetle) and press it. Once the code is loaded on
the board, verify it works by going to Run->Resume, which
will release the code to run (after loading, the code execution
is paused by default under debug mode). If successful, an
LED on the board will begin blinking on and off.
Part 3 (Custom "Blinky" example)
- Now that you have blinky running, let's play with it and
change it to our own liking.
- Read through the code provided in the Blinky project.
The code you are interested in will be in the following
folders: \src, \config, and \driver.
- Modify the proper portions of the code such that you produce a
change in both the frequency and duty cycle of the blinking
LED. Don't make the frequency so fast that the TAs can no
longer see discrete blinking! (Note: The human eye cannot
distinguish faster than about 24-30 Hz).
Part 4 (Linking together the ADC (input) and GPIO (output)
- For this portion of the lab, you will complete a data flow
beginning from an analog ADC port on the LPCXpresso board, and
ending with the digital I/O pin on the GPIO port. We will
apply a sine wave generated by the Agilent Function Generator in
your work area. Our
intended end result should be as follows. The LED
should be ON when the voltage applied to the AD0 pin is greater
than Vcc/2, and the LED should be OFF when the voltage is less
than Vcc/2. Lastly, display the current frequency in the
debug_print window, you will probably need to use a timer.
- We will begin by using the "adc" example project from the
example projects zip file that you have already downloaded and
installed in Part 2 of this lab as our base. We have
modified the main c file, which is available for you here. Download and
replace the current c file in the adc example project with this
- Next, we will need to modify some of the project settings to
allow the compiler to find the necessary control drivers for to
operate the GPIO pin that drives the LED (these files are
omitted from consideration to reduce the size of the resulting
code--code space is a critical resource in an embedded
system!). For this, first add the following line of code
somewhere in the /config/driver_config.h file. This
satifies some of the preprocessor directive checks in the GPIO
driver source files found in /driver/gpio.c and /driver/gpio.h
(have a look and you can see for yourself).
- #define CONFIG_ENABLE_DRIVER_GPIO 1
- Next, we need to tell the compiler not to ignore these new
GPIO driver files, which previously went unused in the adc
example (conversely, in the LED 'blinky' project you are already
familiar with, the adc driver files are similarly
disabled). For this, right-click on the adc project and
select properties, then follow the below Figure 2 to complete
- Now compile the project to make sure there aren't any errors
("Build 'adc' project [Debug]") in the Quick Start menu.
2. The gpio.c, gpio.h filter removal procedure
(click to enlarge).
- Configure the function generator using the below parameters
to start with.
Wave Type: Sine
Frequency: 1.0 Hz
Voltage offset: 1.0 V
Voltage P2P: 1.0 Vp2p
- Using the supplied probes (next time you will need to supply
your own that you hopefully still have in your ECEN-1400 kit),
attach the ground side to the board's ground, and the probe
side to the AD0 pin (wire will be supplied to make the ground
connection easier, but you may still have to hold them in
- Write the code in the modded_adc_main.c file needed to light
the LED when the voltage is greater than Vcc/2.
- Write code that can infer the frequency of any sinusoidal
signal with a 1 V offset and 1 Vp2p setting. Print the
frequency in real-time to the screen using debug_printf.
Hint: you may need to use a timer for this.