Concurrency in embedded systems allows multiple tasks to run within the same system. In this project, timer interrupts and task scheduling were used on the RT-Spark development board to manage different tasks and respond to events efficiently.'
Hardware SetupThe LEDs were configured as outputs, while the user button was configured as an external interrupt source. The hardware used in this project includes:
- RT-Spark Development Board
The background tasks are handled by interrupt service routines (ISRs), while the foreground tasks run inside the main loop. Timer interrupts set flags that signal the main loop to execute specific tasks. This approach allows the system to perform multiple operations while remaining responsive.
ImplementationThe timers and external interrupt were configured using STM32CubeMX and implemented in STM32CubeIDE and the two hardware timers were configured to generate interrupts at different intervals.
- Timer 2 toggles the red LED every 1 second.
- Timer 3 toggles the blue LED every 0.5 second.
- Pressing the button immediately toggles both LEDs.
- The main loop executes tasks based on flags set by the timer interrupts.
The timers and external interrupt were configured using STM32CubeMX and implemented in STM32CubeIDE.
ResultsThe project successfully demonstrated timer interrupts, task scheduling, and event-triggered behavior.
Timing MeasurementThe timing analysis produced the following results:
- TRelease (TIM2): 1.0 second
- TLatency (Task A): 24.94 µs
- TISR (TIM2): 4.31 µs
- TTask (Task A): 50 ms
- TResponse (Task A): 50.02443 ms
The red LED blinked every 1 second.
- The blue LED blinked every 0.5 second.
- The button interrupt responded immediately when pressed.
- Multiple tasks were handled efficiently using interrupts and flags.
The project showed that interrupt-based scheduling is more responsive than polling. Timer interrupts allow tasks to be executed at specific intervals, while the button interrupt responds immediately to user input. The foreground/background architecture also helps organize tasks efficiently and improves system responsiveness.


Comments