Modern Embedded Architecture
Moving beyond the Super Loop: RTOS, HALs, and the separation of concerns.
The days of writing everything in a single main.c file are over. Modern embedded systems are expected to handle
Wifi, Bluetooth BLE, complex sensors, and OTA updates simultaneously.
This requires a robust architecture.
1. The Evolution
while(1) { check_sensor(); update_led();
}
Simple, deterministic, but blocks easily. Impossible to
scale.
Preemptive multitasking. Tasks (Threads) communicate via Queues and Semaphores.
Full OS. Memory management (Scaling), Filesystems, Drivers. High overhead but immense power.
2. Decoupling Hardware (HAL)
A modern firmware architecture separates the Business Logic from the Hardware.
- Application Layer: "Send telemetry every 5 minutes." (Doesn't care if it's Wifi or LoRa).
- HAL (Hardware Abstraction Layer): standard
interfaces like
network_send()orgpio_set(). - BSP (Board Support Package): The dirty code that actually toggles the registers for a specific STM32 or ESP32 chip.
3. Modern Event-Driven Design
Instead of polling ("Are we there yet?"), modern systems are Interrupt Driven.
- Interrupt (ISR): The hardware wakes up the CPU. "Hey, Data arrived!"
- Deferred Work: Do NOT process data in the ISR. Flag a semaphore or send a message to a Queue.
- Event Loop: The main thread wakes up, processes the message, and goes back to sleep (Low Power).
Connect & Discuss
Have questions about systems engineering, or found a bug in the code? Reach out!
Feedback
This blog is a static site, but I'd love to hear your thoughts. You can discuss this post by sending me an email or reaching out on social media.
Send Feedback