What is anEmbedded System ?
An embedded system is a microcontroller or
microprocessor-based system which is designed to perform
a specific task.
An embedded system can be an independent system or it
can be a part of a large system.
For Example: Fire alarm, Washing machine and Medical
instruments
3.
Constraints in EmbeddedSystems
Limited Memory
Embedded systems have limited RAM/ROM
Low Processing Power
Processing power of Embedded systems are limited
Limited Battery Life
Battery life is often a constraint
Real Time Needs
Often requires real time data
4.
What Does “EfficientCode” Mean?
• In embedded systems, memory is often limited. Efficient
code minimizes the memory usage.
• Many embedded systems are battery-powered, and efficient
code can significantly extend the device's operational
lifespan. By minimizing power consumption.
• Efficient code optimizes processing speed. Faster execution
speeds lead to quicker response times and improved
system performance.
5.
Tips for WritingEfficient Code
Prefer using efficient data types like uint8_t instead of int to reduce memory usage and
improve performance.
Avoid floating-point arithmetic whenever possible, as it tends to be slower and more
power-hungry than fixed-point or integer operations.
Optimize loops and conditional logic by minimizing nesting and checking the most likely
conditions first.
Reduce function calls in time-critical code.
6.
Memory Management inEmbedded Systems
Embedded systems often have limited memory , both RAM and ROM , so smart
memory management is crucial for performance, stability and power efficiency.
ROM: Stores permanent firmware code
RAM: Used to store temporary data during execution
7.
Key Points toRemember While Working with Memory
• Avoid dynamic memory allocation like malloc() in real-time systems, as it
can cause fragmentation and lead to unpredictable behavior.
• Clean up unused variables to reduce memory footprint and avoid wasting
space in embedded systems.
• Use the smallest appropriate data types.
• Enable compiler warnings to catch errors early during development.
• Use static or global Variables When Needed.
8.
Conclusion
Efficient Code
In simpleterms efficient code is Faster,
Smaller, and smart. Importance
It improves execution speed, makes
efficient use of memory, and enhances
code readability for long-term maintenance.
In embedded systems, even small decisions make a big impact