Project case study
Microcontroller peripheral labs
C coursework exploring the connection between physical inputs, interrupt handlers, and microcontroller peripherals.
The problem
Responding to a button press or a timer event requires software to cooperate with the microcontroller’s hardware. These labs explore that boundary through GPIO configuration, interrupt service routines, timer setup, PWM output, and SPI transfers.
The work is preserved as separate C source files. The final program brings together button and timer interrupt handlers with LED and PWM output control; a separate lab explores SPI communication.
How the source is organized
| Source | Responsibility | Hardware concepts |
|---|---|---|
| finalcode.c | Configure inputs and outputs; handle button and timer events. | GPIO, external interrupts, Timer2, Timer3, OC1 PWM. |
| lab9.c | Configure SPI1 as a master and transmit lookup bytes from a button interrupt. | SPI configuration, byte transfers, interrupt handling. |
Events drive the output behavior
The final source uses an external interrupt handler to update LED and PWM output control. A Timer3 handler provides a separate timed LED behavior. Timer2 and the output-compare peripheral provide the PWM mechanism.
Peripheral setup is explicit
The code exposes register configuration directly. This makes input/output direction, timer setup, interrupt flags, and peripheral control part of the implementation rather than hiding them behind a high-level library.
Evidence & verification
The public artifact is source code. It shows the peripheral configuration and intended event handling, but does not include a reproducible build configuration, a hardware test log, oscilloscope captures, or measured timing results.
What would strengthen the project
A documented board and toolchain setup would make the lab easier to reproduce. Useful next evidence would include logic-analyzer captures of SPI, measured PWM output, and checks for repeated button presses and interrupt-flag handling.