This repository contains a collection of example projects originally developed in 2012 for an introductory ARM programming course at IAUCTB. The examples were designed to teach fundamental concepts of microcontroller programming using the ARM7 LPC214x series. These examples demonstrate various GPIO operations, from basic LED control to seven-segment display implementations, using different programming approaches that progressively increase in complexity.
The repository is organized into eight progressive examples:
-
Basic Switch & LED Control (E01)
- Simple GPIO operations with one switch controlling two LEDs
- Direct port manipulation
- Basic input/output concepts
-
Dual Switch & LED Control (E02)
- Independent control of two LEDs using two switches
- Multiple GPIO input/output handling
-
Seven Segment Display Basic (E03)
- 7-segment display control using macros
- Multiple switch inputs
- BCD to 7-segment conversion
-
Single Switch & LED Macro (E04)
- LED control using macro definitions
- Improved code organization
-
Dual Switch & LED Macro (E05)
- Extended macro usage for multiple I/O
- More complex logic handling
-
Single Switch & LED Library (E06)
- Introduction to custom libraries
- Modular code structure
- Hardware abstraction layer basics
-
Dual Switch & LED Library (E07)
- Extended library implementation
- Multiple device handling
- Clean code architecture
-
Seven Segment Display Library (E08)
- Complete library-based implementation
- Advanced hardware abstraction
- Modular and reusable code
- IAR Embedded Workbench for ARM 8.22.1 or later
- NI Circuit Design Suite v14.0.1 or later
- Proteus Pro 8.6 SP3 or later
The examples are tested on the NXP LPC2148 microcontroller and are compatible with the LPC2130~LPC2148 family.
- IAR Embedded Workbench for ARM (recommended) or equivalent ARM toolchain
- One of the following simulation tools:
- Proteus Design Suite (for circuit simulation)
- NI Circuit Design Suite (for circuit simulation)
- LPC214x development board (optional, for physical testing)
- Basic understanding of C programming
- Knowledge of GPIO concepts
- Familiarity with digital circuit simulation tools
- Clone this repository
- Open the desired example project in IAR Embedded Workbench
- Build the project
- Set up the circuit in Proteus or NI Circuit Design Suite:
- Create new schematic
- Add LPC2148 microcontroller
- Connect LEDs, switches, or 7-segment display as per example
- Import the compiled binary
- Run simulation
- Clone this repository
- Open the desired example project in IAR Embedded Workbench
- Build the project
- Flash the compiled binary to your LPC214x board
- Connect the hardware components according to pin definitions
- LEDs connected to specified GPIO pins (see individual project documentation)
- Switches connected to specified input pins
- Proper current-limiting resistors for LEDs
- Common cathode 7-segment display
- Connected to P1.17 through P1.23
- Input switches for digit selection
- Open Proteus Design Suite
- Add the microprocessor: Library => Microprocessor ICs => LPC => 2148
- Connect components according to the pin configurations in each example
// Set bit n to 1
R |= (1UL << n); // UL ensures 32-bit operation
// Clear bit n to 0
R &= ~(1UL << n);Using IOxDIR registers (x = 0 or 1 for respective ports):
// Configure pin as output
IO0DIR |= (1UL << 3); // P0.3 as output
IO1DIR |= (1UL << 8); // P1.8 as output
// Configure pin as input
IO0DIR &= ~(1UL << 2); // P0.2 as input
IO1DIR &= ~(1UL << 4); // P1.4 as input// Set pin to high (3.3V)
IO0SET |= (1UL << pinNumber);
// Set pin to low (0V)
IO0CLR |= (1UL << pinNumber);Contributions are welcome! Please feel free to submit pull requests with improvements or additional examples.
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or issues, please open an issue in the repository.