- Definition: An embedded system is a dedicated computing device designed to perform specific tasks within a larger mechanical or electrical system. Unlike general-purpose computers, they have constrained resources and must operate reliably for long periods.
- Core components: Every embedded system includes a microcontroller or microprocessor, memory (RAM, ROM, flash), input/output interfaces, and often sensors or actuators. The microcontroller integrates CPU, memory, and peripherals on a single chip.
- Real-time requirements: Many embedded systems must respond to events within strict time bounds. Hard real-time systems (e.g., airbag controllers) have deadlines that cannot be missed, while soft real-time systems (e.g., temperature monitors) tolerate occasional delays.
- Common applications: Embedded systems are found in consumer electronics (microwaves, smart TVs), automotive (engine control units, infotainment), medical devices (pacemakers, infusion pumps), industrial automation (PLC, robotics), and IoT nodes (smart sensors).
- Design constraints: Developers must optimize for power consumption, cost, size, memory, and processing speed. Tradeoffs are common; for example, increasing clock speed raises power draw.
- Development flow: Typical workflow includes requirements analysis, component selection, schematic design, PCB layout, firmware development, integration testing, and certification. Version control and documentation are critical for maintenance.
- Key metrics: Performance is measured by throughput, latency, power efficiency (mW/MIPS), reliability (MTBF), and bill of materials cost. Selection of microcontroller involves balancing these metrics.
- Trends: Current trends include multicore processors, edge AI, wireless connectivity (Bluetooth Low Energy, Wi-Fi 6), and functional safety standards (ISO 26262 for automotive, IEC 62304 for medical).
- Debugging and testing: Embedded systems require specialized debug tools like JTAG/SWD probes, logic analyzers, and oscilloscopes. Developers use breakpoints, watchpoints, and trace features to inspect runtime behavior. Testing includes unit tests, integration tests, and hardware-in-the-loop (HIL) simulations to validate real-time constraints and corner cases.
- Firmware update mechanisms: Over-the-air (OTA) updates enable remote firmware upgrades via wireless protocols like BLE, Wi-Fi, or cellular. Systems often use dual-bank flash (A/B partitions) to allow rollback on failure. Secure boot and cryptographic signatures ensure update authenticity and integrity.
- Real-time operating systems (RTOS): Many embedded systems use an RTOS like FreeRTOS, Zephyr, or ThreadX to manage tasks, scheduling, and inter-task communication. The scheduler uses priority-based preemptive or cooperative multitasking. Key RTOS features include semaphores, mutexes, message queues, and timers.
Pattern: Single Microcontroller (MCU) Architecture
Components:
- Processor Core: ARM Cortex-M series (or RISC-V) runs firmware stored in flash memory. Clock speeds range from 8 MHz to 600 MHz depending on application.
- Memory: SRAM stores stack and heap data; flash holds non-volatile code and configuration. Typical sizes: 16 KB - 2 MB flash, 2 KB - 512 KB SRAM.
- Peripherals: GPIO, timers, ADC, UART, I2C, SPI, USB, CAN, and DMA are integrated on-chip. Each peripheral has configurable registers to control behavior.
- Power Management: Low-power modes (sleep, deep sleep) disable clock trees to reduce current from milliamps to microamps. Wake-up sources include external interrupts and real-time clock.
#include 'mcu.h'
int main(void) {
// Configure LED output on GPIO pin 5
GPIO_DIR_SET(GPIO_PORTB, 5);
while (1) {
GPIO_TOGGLE(GPIO_PORTB, 5);
delay_ms(500);
}
return 0;
}This minimal program initializes a GPIO pin as output, then toggles it every 500 ms to blink an LED. The mcu.h header abstracts hardware-specific register definitions.
- Embedded systems are specialized computers with constrained resources, designed for dedicated tasks.
- Typical components: microcontroller, memory, I/O, and power management.
- Hard real-time systems have strict deadlines; soft real-time systems tolerate some latency.
- Design tradeoffs involve cost, power, size, and performance.
- Modern trends include edge AI, wireless connectivity, and functional safety.