When one mentions the words programming language in a conversation, he or she is almost guaranteed to get a response saying that data science and artificial intelligence is the future, and one must only learn programming languages that are aligned with that. Well that may be true, but most people overlook embedded programming.
We use devices programmed by embedded programmers every day without even noticing it. So what exactly is embedded programming?
In this article I answer this very important question. I hope you will enjoy it!
Table of Contents
- 1 Embedded Programming Definition
- 2 What is an embedded system?
- 3 Embedded System Requirements and considerations
- 4 Embedded Programming Language Considerations
- 5 The C programming language
- 6 Other Programming languages for Embedded Systems
- 7 Conclusion
Embedded Programming Definition
Embedded programming is the creation of computer software designed and developed to control embedded devices, and is often specialized for the particular hardware that it runs and uses optimized code to use resources present as efficiently as possible.
For one to really understand embedded programming, there is a need to first understand what an embedded system is. Let us start with that now.
What is an embedded system?
An embedded system is defined as a purpose-built computing platform that is designed to accomplish a specific software-controlled task.
Embedded systems typically have limited processing power, limited memory and a long lifetime. When conducting embedded programming of an embedded system, there is a need to investigate the requirements that the embedded system is going to be made to address. After gaining a clear picture of this, then the embedded programmer can then consider other factors such as the best programming language to use.
Embedded System Requirements and considerations
Every embedded system is developed to address a set number of requirements. These determine the factors that are important, and things that can be compromised. An example is if an embedded system is developed with the main requirement being that it should be less than $25 USD, factors such as processing power and memory are definitely going to be compromised as the developer will be forced to use the cheapest components available.
The amount of memory needed for the system to work properly needs to be determined in this stage. It is imperative that the designer gets this stage right as it will be very difficult to address this problem if a mistake is made in this process.
2. Processing power
This refers to the amount of data that the processing device must be able to handle. It is often rated in Millions of Instructions Per Second (MIPS). The programmer must determine how much data his system must be able to handle. In addition features such as the word length i.e. 8 bit vs. 16 bit need to be carefully selected in this stage.
3. Power consumption
Most embedded devices are battery operated. A common way to determine the power requirements for embedded devices is the milliwatts per MIPS rating (mW/MIPS). The programmer needs to know how much battery power he needs for his system to work to meet the requirements present.
In this case, the individual carrying out the embedded programming needs to know how reliable the product needs to be. If the product to be made is non critical, e.g. if it is something like a washing machine then the reliability does not need to be 100% If, however, the project is going to be used in medical or military applications, then the individual doing the embedded programming needs to ensure that the device is going to be available all the time – 100%.
This is the last thing to consider when developing the system. In this case, the individual carrying out embedded programming needs to know how long the product is intended to stay in use. This will determine things such as whether to add expansion slots, whether to add more memory, etc.
Embedded Programming Language Considerations
After these considerations comes the implementation. In this stage, the programmer decides which language is the best language to use. Since embedded systems have very limited resources, they need to be managed as efficiently as possible. As a result the programming language used needs to be as close to the hardware as possible – it needs to be low level.
The C programming language
It is quite common to see that across most embedded systems, the C programming language is used. This is because the C programming language acts as both a high level programming language and a low level programming language. C interacts with the hardware in a manner that may leave one categorizing it as a low level language. It also contains human readable syntax, a feature that is common among high level languages.
This results in the language having very many advantages. It is rather easy to learn. There are very many compilers available, and carrying out debugging is quite easy. C is processor dependent which means the programmers can use their time to focus on the instructions they want the system to execute instead of having to learn the architecture of the particular processor.
There are a very few high level programming languages that can compete with C in creating compact and efficient code that is able to run on almost all processors.
Other Programming languages for Embedded Systems
In the beginning, embedded programming was mainly done using the assembly language of the target processor. This allowed programmers to gain complete control of the processor and other hardware, but this was quite a trade-off. Assembly language lacks code portability, finding skilled assembly language programmers is quite difficult. It is mainly used for small pieces of code that really need to be extremely efficient or cannot be written any other way.
C++ is another choice. It is an object-oriented superset of C. It has the same core language features as C and adds new functionality for better data abstraction and a more object-oriented style of programming.
Ada is another object-oriented language. It has not gained a foothold outside of defence and aerospace industries.
Python is another choice that is available. It has the advantages of being fast, less prone to errors and is more readable than C or C++. In the future it could dethrone C from the number 1 position in embedded programming. Who knows?
Well, that’s enough learning for today. I hope you now understand what embedded programming is, and why C is still popular.