Skip to Main Content
Programming Embedded Systems, 2nd Edition
book

Programming Embedded Systems, 2nd Edition

by Michael Barr, Anthony Massa
October 2006
Intermediate to advanced content levelIntermediate to advanced
336 pages
9h 13m
English
O'Reilly Media, Inc.
Content preview from Programming Embedded Systems, 2nd Edition

The Blinking LED Program

Almost every embedded system that we’ve encountered in our respective careers has had at least one LED that could be controlled by software. If the hardware designer plans to leave the LED out of the circuit, lobby hard for getting one attached to a general-purpose I/O (GPIO) pin. As we will see later, this might be the most valuable debugging tool you have.

A popular substitute for the “Hello, World!” program is one that blinks an LED at a rate of 1 Hz (one complete on-off cycle per second). [1] Typically, the code required to turn an LED on and off is limited to a few lines of code, so there is very little room for programming errors to occur. And because almost all embedded systems have LEDs, the underlying concept is extremely portable.

Our first step is to learn how to control the green LED we want to toggle. On the Arcom board, the green LED is located on the add-on module shown in Figure 3-1. The green LED is labeled “LED2” on the add-on module. The Arcom board’s VIPER-Lite Technical Manual and the VIPER-I/O Technical Manual describe how the add-on module’s LEDs are connected to the processor. The schematics can also be used to trace the connection from the LED back to the processor, which is typically the method you need to use once you have your own hardware.

Arcom board add-on module containing the green LED

Figure 3-1. Arcom board add-on module containing the green LED

LED2 is controlled by the signal ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming with STM32: Getting Started with the Nucleo Board and C/C++

Programming with STM32: Getting Started with the Nucleo Board and C/C++

Donald Norris

Publisher Resources

ISBN: 0596009836Supplemental ContentErrata Page