http://dreamcatcher.
asia/cw
ME2100 Embedded System Design (ARM9TM)
Lab 4
Peripheral Control Using ARM®
This courseware product contains scholarly and technical information and is protected by copyright laws
and international treaties. No part of this publication may be reproduced by any means, be it transmitted,
transcribed, photocopied, stored in a retrieval system, or translated into any language in any form, without
the prior written permission of Acehub Vista Sdn. Bhd.
The use of the courseware product and all other products developed and/or distributed by Acehub Vista
Sdn. Bhd. are subject to the applicable License Agreement.
For further information, see the Courseware Product License Agreement.
Objective
i) Develop the C version of the program to perform the following:
— display hexadecimal data on the 7-segment LED display
— monitor the onboard 8-way DIP switch
Equipment Required
i) ME2100 Embedded ARM9 Development Board
ii) Analog and Digital Oscilloscope: 100 MHz, 2 analog and 16 digital channels
Accessories Required
i) 1 x 5 V power adapter
ii) 1 x Type A-to-Type B USB cable
iii) A PC running Microsoft® Windows 10 with a minimum of 512 MB RAM, and pre-installed with the
open source GNU-based ARM9 toolchain (Refer to the ME2100 Quick Start Guide for the
installation procedures)
ME2100 Embedded System Design (ARM9™) Lab 4 - 1/7
http://dreamcatcher.asia/cw
1. Introduction
Operations of more elaborate I/O peripherals typically require the use of multiple interface lines. Two
peripherals on the embedded ARM9 development board — the 7-segment LED display and the 8-way
DIP switch — will be examined in this laboratory. Compared to LED indicators and push buttons, the
7-segment LED display and the 8-way DIP switch require multiple I/O interface lines to operate.
2. Seven-Segment LED Display
A 7-segment LED display is a much more informative device, than an on-off LED indicator, for displaying
data. The embedded ARM9 development board contains the HDSP-433G common-cathode 3-digit LED
display as shown in Figure 1. This display is internally organized into four groups; three groups for the
three digits, and one group for the L1 to L3 Lamp indicators. Bit segments of all the groups are shared
through the common data pins A–G and DP1–DP3.
Figure 1 – Seven-Segment 3-Digit LED Display Connection
On the embedded ARM9 development board, this 7-segment LED display is driven by a dedicated LED
controller (MC14489) with a Serial Peripheral Interface (SPI) based connection at the host (processor)
side. As such, it is connected to the SPI interface lines of the AT91RM9200 (MOSI, SCLK, and NPCS0 in
SPI mode) as shown in Figure 2. However, in this exercise, the LED display will be controlled using the
bit-banging approach, where the interface lines are toggled according to the operating specifications, to
perform the data transfer directly. (Direct SPI-controlled operation will be investigated in a later exercise).
Figure 2 – Seven-Segment LED Controller Interface
ME2100 Embedded System Design (ARM9™) Lab 4 - 2/7
http://dreamcatcher.asia/cw
The LED controller, MC14489B, can drive up to five banks of LED displays, selected through its B1 to B5
bank select signal. Only the control signals of four banks are used for the embedded ARM9 development
board because the LED display is organized internally into four groups. The controller automatically
multiplexes the data for the each bank among the banks once it is configured properly.
To use the controller to drive the display, the controller needs to be first initialized with an 8-bit command
data with the timing signal and the format as shown in Figure 3. Each data bit is captured at the rising
edge of the clock signal when the ENABLE line is asserted (active low). An appropriate command data
value for this laboratory exercise is 0x61; this data value turns on the LED segment, display the data for
banks 1 to 3 in Hex Decode mode (i.e., hexadecimal format), and display the data for bank 5 in No
Decode mode (Lamp format). (See the MC14489B data sheet for details of the various settings
available).
Figure 3 – Command Data Mode
The data to be displayed on each bank is then sent by the processor through a 24-bit data format, as
shown in Figure 4. The controller differentiates between the command data and the display data through
the number of clocks detected when its ENABLE signal is asserted. (See the MC14489B data sheet for
details).
Figure 4 – Display Data Mode
The display data for bank 1 to bank 3 is encoded in the hexadecimal 4-bit nibble form, and sent through
D0 to D11. The decimal points of each digit is set through D20 to D22, The display data for bank 5, that
corresponds to the three Lamp indicators (L1, L2, and L3), is not encoded and each indicator can be
controlled by the setting of the individual bits D16, D17, and D18 respectively.
Exercise
Based on the information presented, and with reference to the data sheet of MC14489B, write a C routine
to display hexadecimal coded data on the 3-digit 7-segment LED display. Single step through the
program using the Eclipse-JTAG debugger to verify the logic sequence of the program flow. To further aid
in the debugging of the program code, use an oscilloscope to observe the I/O interface lines and compare
your observation with the timing diagrams shown in Figure 3 and Figure 4.
ME2100 Embedded System Design (ARM9™) Lab 4 - 3/7
http://dreamcatcher.asia/cw
3. Eight-Way DIP Switch
A slightly more complicate on-board peripheral on the embedded ARM9 development board is an 8-way
DIP switch that is interfaced to the AT91RM9200 microprocessor through a Parallel-Load Shift register as
shown below.
Figure 5 – Eight-Way DIP Switch Interface Circuitry
The basic operation sequence of the circuit is to first make the shift register load its parallel input data
lines (D0 to D7) into its internal register. This is followed by clocking out the data serially through its serial
output (Q7). The various control signals needed to enable these operations are as follows:
i) PL: the parallel load input data at D0 to D7 (active low)
ii) CLK: the clock signal used to serially clock the data out at Q7 (during the positive rising edge)
iii) CE: Clock Enable (active low)
Figure 6 shows the timing sequence of the signals during a typical operation.
ME2100 Embedded System Design (ARM9™) Lab 4 - 4/7
http://dreamcatcher.asia/cw
Figure 6 – Timing Diagram of the 74HC165 During Operation
From Figure 5, the various control signals of the shift register are interfaced to the ARM processor as
follows:
i) PL: connects to PB0 (or PA26, depending on the soldered resistor)
ii) CLK: connects to PA2
iii) CE: connects to PA4
iv) Q7: connects to PA0
Hence, by toggling these I/O pins in the proper sequence, and sample the serial line at the appropriate
instances, the processor would be able to read the position of the eight dip switches.
Exercise
Write a C program to poll the status of the eight dip switches. Use the LED indicator program developed
in Section 2 to flash one of the LED indicators (e.g., LD4) to show that the program is continuous polling
the DIP switches. Turn on the three onboard LED indicators in various combinations (2 3 = eight possible
combinations) to reflect the positions of the eight switches.
Review the earlier laboratory exercises (Section 2 and Section 3) to examine the necessary settings of
the various PIO registers to enable their I/O lines accordingly. It should also be clear by now that many of
these functions are routinely required in typical ARM programming. As such, Atmel® has also made
available another include file, lib_AT91RM9200.h that contains the various inline functions commonly
used for the AT91RM9200 microcontroller. In this exercise, the student should explore this file and make
use of the relevant functions. Examples of these functions that can be used in this exercise are listed
below.
void AT91F_PMC_EnablePeriphClock (AT91PS_PMC pPMC, unsigned int
periphIds);
void AT91F_PIO_CfgOutput(AT91PS_PIO pPio, unsigned int pioEnable);
void AT91F_PIO_SetOutput(AT91PS_PIO pPio, unsigned int flag);
void AT91F_PIO_CfgInput(AT91PS_PIO pPio, unsigned int inputEnable);
void AT91F_PIO_ClearOutput(AT91PS_PIO pPio, unsigned int flag);
unsigned int AT91F_PIO_GetInput(AT91PS_PIO pPio);
ME2100 Embedded System Design (ARM9™) Lab 4 - 5/7
http://dreamcatcher.asia/cw
To debug the program, it is essential to use the analog and digital oscilloscope to monitor the timing of the
various relevant signals shown in Figure 2, as the program is run or single-step using the Eclipse-JTAG
debugger system.
4. Optional Exercise
Combine the DIP switch program code and the 7-segment LED display program code; use the 7-segment
LED display to show the values that correspond to all the possible binary combinations of the eight
switches (i.e., from 0 to 255).
5. Reference
[1] MC14489B Datasheet, “Multi-Character LED Display/Lamp Driver”, Freescale™ Semiconductor, Inc.
ME2100 Embedded System Design (ARM9™) Lab 4 - 6/7
http://dreamcatcher.asia/cw
Revision History
Revision Description
1.05 Lab sheet update for Windows 10 compatibility.
ME2100 Embedded System Design (ARM9™) Lab 4 - 7/7