What is embedded?
- C course
- Expert
- Lesson 37/47
- 5 min
Learn the embedded system concept and constraints.
What is an embedded system?
An embedded system is a resource-constrained computer designed to perform a specific task. It runs on a microcontroller (MCU) with limited RAM, ROM and power. Examples: car engine control, smart watch, microwave oven.
In embedded C programming, constraints are decisive. Memory is scarce (a few KB), the processor is slow (MHz range), and power consumption is critical. So writing efficient code is mandatory. Standard library usage is limited; functions like printf are often absent. Instead, hardware is controlled directly through memory-mapped I/O (MMIO). Embedded C teaches working within these constraints.
Embedded C constraints
Embedded C programming has three main constraints: memory, speed and power. The memory constraint usually makes dynamic allocation (malloc) impractical; static allocation is preferred instead.
The speed constraint requires efficient algorithms; every loop iteration counts. The power constraint requires putting the processor to sleep and waking it with interrupts. Embedded code typically runs in an infinite loop: while (1) { ... }. This loop keeps the system running and responds to hardware events. Each constraint directly shapes the code structure.
Practice Print embedded constraints
Define int ram_size = 1024; and int cpu_speed = 16;. Write int main(void); print with printf("Bellek: %d\n", ram_size), printf("Hız: %d\n", cpu_speed) and printf("Hazır\n").
Starter code
#include <stdio.h>
// bellek ve hız değişkenlerini tanımla
// main'de üç satır yazdırSample solution
#include <stdio.h>
int ram_size = 1024;
int cpu_speed = 16;
int main(void) {
printf("Bellek: %d\n", ram_size);
printf("Hız: %d\n", cpu_speed);
printf("Hazır\n");
return 0;
}Expected output
Bellek: 1024 Hız: 16 Hazır
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which of the following is typical in an embedded system?
- MHz-range processor speed Correct answer
- Unlimited RAM
- Full standard library
- Gigabyte disk
Explanation: Embedded systems typically run at MHz-range speeds.
2 Complete the memory size
int ram_size = ____; /* KB cinsinden */
int ram_size = 1024; /* KB cinsinden */
Explanation: In embedded systems, 1024 KB (1 MB) is already generous.
3 Match constraint to type
| Term | Meaning |
|---|---|
Memory |
KB range |
Speed |
MHz range |
Power |
mW range |
Loop |
Infinite while |