Lab guides for Introduction to Embedded Systems

This site is under development with an expected completion of January 1, 2025. Until then, all content is subject to change without warning.

This is a collection of lab guides for the course EN 173: Introduction to Embedded Systems taught by John Larkin at Whitworth University. The development board used throughout these guides is Nordic Semiconductor’s nRF52840 DK. In addition, Nordic Semiconductor’s nRF Connect SDK and the associated Visual Studio Code extension are used to provide a development environment that is relatively accessible for a student first encountering embedded systems. However, the course also targets the Zephyr RTOS which is designed to be portable across a broad selection of platforms so much of what is found in these guides should be applicable to other microcontrollers with only minor changes.

Lab 1 — Getting Started

In this set of activities you will:

  • install the development environment,

  • create a simple program to flash an LED on the development board,

  • transfer that program to the development board, and

  • learn how to document the program using Markdown.

Additional hardware required: none

Lab 2 — Basic Digital Input and Output

In this set of activities you will:

  • use a button internal to the development board,

  • connect the development board to external circuit elements (LEDs and resistors),

  • modify the devicetree to enable use of additional digital output pins, and

  • use an oscilloscope to observe the output of a GPIO pin.

Additional hardware required:

Lab 3 — Going Deeper with Digital Input and Output

In this set of activities you will:

  • modify the devicetree to enable use of additional digital input pins,

  • use an external slide switch and momentary push button,

  • and use a photointerrupter to detect light-blocking events.

Additional hardware required:

  • two LEDs (described as red and green in instructions)

  • two 330 Ω resistors

  • slide switch (SPDT)

  • momentary push button (SPST)

  • photointerrupter (Isocom H21A1)

  • 10 kΩ resistor

Lab 4 — Direct GPIO Port Writing and Reading

In this set of activities you will:

  • set the state of multiple pins on the same GPIO port with a single command,

  • get the state of all of the pins on a GPIO port with a single command,

  • use multi-pin writes to control a seven-segment display, and

  • begin to use functions to make your code more modular.

Additional hardware required:

Lab 5 — Pulse-Width Modulation

In this set of activities you will:

  • blink an LED using pulse-width modulation (PWM),

  • use PWM to control the brightness of an LED,

  • use PWM to control the position of a servo, and

  • observe the output of the PWM signal on an oscilloscope.

Additional hardware required:

  • LED (described as red in the instructions but the color is not critical),

  • 330 Ω resistor,

  • 10 kΩ resistor,

  • 10 kΩ resistor,

  • 10 µF capacitor,

  • oscilloscope (instructions describe usage of Digilent’s Analog Discovery 2),

  • servo (instructions describe a Hitec HS-422 servo), and

  • 6 V battery pack (optional if using a low-voltage servo such as the TowerPro SG92R that can be powered directly from the development board).

Lab 6 — Analog Input

In this set of activities you will:

  • configure an ADC channel to read an analog voltage,

  • use a potentiometer to vary the voltage on an ADC channel,

  • measure light intensity with a light-dependent resistor (photocell), and

  • measure temperature with an analog temperature sensor.

Additional hardware required:

  • 10 kΩ potentiometer,

  • voltmeter (instructions describe Digilent’s Analog Discovery 2),

  • oscilloscope (Digilent’s Analog Discovery 2),

  • light-dependent resistor (photocell), and

  • TMP36 temperature sensor.

Lab 7 — SPI Communication

In this set of activities you will:

  • observe SPI communication using a logic analyzer and

  • communicate with an accelerometer using SPI.

Additional hardware required:

Lab 8 — I2C Communication

In this set of activities you will:

  • communicate with a digital temperature sensor using I2C,

  • observe I2C communication using a logic analyzer, and

  • communicate with a magnetic field sensor using I2C.

Additional hardware required:

Lab 9 — Timers and time-based interrupts

In this set of activities you will:

  • use a timer with polling,

  • use a timer with a callback function,

  • measure latency, and

  • use timers to record temperature at periodic intervals.

Additional hardware required:

  • 330 Ω resistors (2),

  • LEDs (2),

  • momentary push button,

  • oscilloscope (instructions describe usage of Digilent’s Analog Discovery 2),

  • and TMP36 analog temperature sensor.

Lab 10 — Event-based interrupts

In this set of activities you will:

  • respond to a button press with an interrupt,

  • use a timer to debounce a button,

  • use an RC filter to debounce a button, and

  • use a comparator to generate a temperature-based interrupt.

Additional hardware required:

  • LED,

  • 330 Ω resistor,

  • 1.5 kΩ resistor,

  • 10 kΩ resistor,

  • 10 µF capacitor,

  • momentary push button,

  • TLC272 op amp,

  • TMP36 analog temperature sensor, and

  • oscilloscope (for example, Digilent’s Analog Discovery 2).

Lab 11 — Threads

In this set of activities you will:

  • create a thread to blink an LED,

  • pass parameters to a thread at its creation,

  • compare the performance of threads and interrupts to button presses, and

  • use a thread to record temperature at periodic intervals.

Additional hardware required:

Lab 12 — Mutexes and Message Queues

In this set of activities you will:

  • control access to a set of LEDs with a mutex,

  • use a message queue to pass data between threads, and

  • apply these concepts to a temperature logging application.

Additional hardware required:

  • TMP36 analog temperature sensor,

  • TMP102 digital temperature sensor, and

  • to be determined.