Starting your Career in Embedded System Design and Programming — PART 1

Ajay Rajan
12 min readDec 30, 2019

--

This blog post series is intended for beginners and intermediate audience who wish to start a career in Embedded system design.
The tools & techniques that you will learn if you follow along the post, will give you an in-depth knowledge & confidence to be able to create robust code+hardware as well as secure good jobs/internships.
I will start with why you shouldn’t continue doing your projects on Arduino — I don’t have any thing against it but, as you read along you’ll realize how much you are missing out if your only embedded experience is with an Arduino IDE.

This is not an educational post, this is a collection of resources and the order in which they must be utilized.

So, Arduino has a huge popularity among embedded and software developers. The quickest way to rapid prototype a product/project, thanks to the massive library + community support.
But the main question that we will address in this article is — “Do we really learn embedded system design using an Arduino IDE?”

The straight up answer is — “Ehh, Maybe?”.

Very few people are actually sure. More or less, it depends on how you tackle a project using an Arduino.
By this I mean, I did a little mistake by buying an Arduino without having worked on an 8-bit controller such as AT89C51 or PIC first.

Arduino is like a smart/confident lady, and without the knowledge of internal architecture/register-level programming/a bit of assembly/basic electronics/C/C++ programming, you are the guy who would not essentially know, how to get her into a serious relationship with you.
Sure you may talk to her, you may joke around. But if you are looking for a long term “hassle-free”, serious relationship, you would need some pre-requisites.

I will now discuss the pre-requisites and the learning curve that will be involved in learning embedded systems from a beginner & intermediate perspective.

If not Arduino, what should be the first step?
Well, the first step undoubtedly remains the 8-bit 8051 Micro-controller.

A 8051 based development kit with a plethora of on-board peripherals

It has a very simple architecture that makes sure that the user is not overwhelmed by its features.
But it has most (not all), peripherals that are required to understand the underlying working of a Micro-controller.
Once you understand how it works, you have to move on to 8085 microprocessor to understand the offerings and computation methodologies of the processor core.

Learning 8051 & 8085

You need to have basic knowledge of C programming language — bitwise, structures/enums/unions and functions() to be precise.
This helps understand the embedded program flow more intuitively.

Now you have to install an IDE (integrated development environment) called KEIL-uvision.
KEIL has a huge fan-base because of its excellent features and a hassle free debugging experience.
After downloading KEIL, you would want to follow this course offered on Udemy by Smart Logic academy.

I mentioned this course primarily because you will learn many things that are actually used in industry as well as get a good hold on creating projects using Assembly language. Follow this book along with the course for a more in-depth experience.

After you understand all the nitty-gritty details of how a Micro-controller works you’d need to start learning about microprocessors.
Follow this Youtube playlist

8085 & 8051

for understanding almost everything that 8085 has to offer. The preferred simulation tool for 8085 is GNUSim8085, you don’t need a hardware kit for this. just keep simulating your codes in this simulator tool.

The most important thing you should understand is the how the program compiles and how the machine code is generated by the compiler, the role of Linker etc.
The above mentioned courses will give you a pretty good insight on this process, however I will demonstrate this once, so you already have a heads up to get started.

The Compilation process:

1. Open OnlineGDB C compiler.

2. Click on Extra compiler flags and write the following script in the dialogue box that opens.

-save-temps

3. Now hit RUN.

Observe main.c, main.i, main.s and main.o

These intermediate files are not usually generated by the compiler.
So what do all of these different files contain? Let’s analyze one at a time

  1. Main.c
    This is your file that you wrote to output a string to the console. “Hello world”. But also observe, to be able to use the printf() functionality you had to #include<stdio.h>, right? So, technically stdio.h is a header file that contains the details of printf() and many many other functions. By #include<> we included this file onto our program, to be able to use its abilities.
  2. Main.i
    This is an intermediate file that essentially clubs the stdio.h file and our code into a single file. i.e Main.i, The compiler at this stage looks for syntax errors. It compares our source code and the code inside the header file such that the function that we are calling in our code, does actually exist inside the header file. For ex. If, in the source code you had called getch(), you would get an compilation error. Because getch() exists only in #include<conio.h>.
  3. Main.s
    The C code has been converted to Assembly instructions inside this file. You can observe there is a one-to-one mapping of the assembly code generated and the C code that you had written (Due to compiler optimization level — low; Will discuss later in the article).
  4. Main.o
    Lastly we have this file generated that contains machine code for your machine to understand. A file ending in .o is an object file. The compiler creates an object file for each source file, before linking them together, into the final executable.

This was an intermediate level understanding of a generic compilation process for a C program. There are more details involved that you will pick up along the way.

Now you have to practice a lot! Learn all about interrupts, serial communication, timers, interfacing sensors, keypads & LCD’s etc. with your 8051 development kit.

Delving deep into 32-bit Architectures —

The transition from 8-bit to 16-bit is not explicit since the 16-bit architectures never superseded the 8 bit Segment. Among other things 16-bit CPUs are often downsized to handle 8 bit peripherals, reducing the data throughput because of resulting I/O bottlenecks. There are also 16 bit Digital Signal Processors, which have become more popular than their 16 bit MPU counterparts because of the need to handle wider data in computation in signal processing applications.

Now we have suddenly come into an era where 32-bit processors are cheaper than 8-bit counterparts. This market push with the ever-increasing features has presented the developer with some difficult 32 bit Processor System design choices in many applications in consumer applications and additional features, connectivity and in Industrial Applications.

Now to get started, you would have to buy yourself a 32-bit board. I would suggest you to buy one of these boards:
1. STM32F446RE Nucleo Board STMicroelectronics.
2. STM32F411RE Nucleo Board STMicroelectronics.
3. STM32F407 Discovery based board by STMicroelectronics.
4. TI -TIVA C series based TM4C123 by Texas Instruments.
5. FRDM-KL25Z by NXP.

After acquiring any one of these boards I would advise you to go through this video if you are not already a Linux power user.
Linux is used extensively in embedded development.
I was myself a Windows fanatic, but when I delved deep I realized I couldn’t ignore Linux for much longer due to its huge applications. Trust me, it is a rewarding experience.
As a programmer you’ll be loving a CLI (command line interface) more than GUI (Graphical user interface) based environment, so why not start now itself?

Linux Power user Course for complete beginners.

First complete this video and then buy and read this book.

Once you are very well acquainted with Ubuntu or any other Linux Distro of your like, you should proceed to these 3 courses offered by MakerMax and FastBit on Udemy. They cover everything you would need to get started with embedded development on ARM-Cortex M based boards. Make sure you complete them in the same sequence mentioned here so that you are able to connect all the dots.

While you are pursuing these courses make sure you have these 2 books alongside for reference codes and practice.

STM32 By Ali Mazidi & ARM CORTEX M by JosephYiu

Now you are almost knee deep in micro-controllers/processor cores and know factually how and why everything works, how to take advantage of driver files and how to create one from scratch, although you might not be able to successfully write one as of now, but you know the architecture of the file and how various function calls, structs etc. interact with one another.

Let’s now take a step back from programming and start building hardware.
Yes, now is a good time to stop programming for a week and learn PCB designing.
This will make you more interested as well as refresh you in case you were feeling burnt out.

PCB designing
Electronic circuits in engineering and industry are normally manufactured by using printed circuit boards (PCBs). These boards are made up of special materials that do not conduct electricity such as fiber and glass. The circuits are designed on the boards with copper tracks instead of wires for the conduction of electricity between the electronic components.

The electronic components are fixed in their respective positions by drilling holes on the board, placing the components and then soldering them in appropriate positions so that the copper tracks and components together form a circuit.The printed circuit boards used in all electronic products such as automotive, wireless devices, Robotic applications, etc., offer quick functioning, access, control, monitoring, and precise and exact results when compared to other wiring methods based devices. The below figure shows how the circuit is arranged on a PCB with the copper layer.

The holes that go all the way through the PCB are used to place through-hole components and some small holes often called as vias are used for inter-layer connectivity. A PCB can be either of 1, 2 or numerous layers. Each layer can offer a specific functionality to the board. One layer can be a ground plane, another can be a signal plane, one of the layers can be used to make traces that carry a specific amount of current so on and so forth.

The ideal PCB design flow begins when designers recognize a need that must be fulfilled, and it does not end until testing verifies that the design can meet those needs.

Ambient temperature range and concerns regarding the operating environment should be addressed and used to specify the materials selected for the PCB.
Components and PCB materials must be selected to guarantee operation under all expected and potential forms of duress the board may be exposed to during its lifetime.

The circuit schematic is drawn based on the concept.

A KiCAD schematic

This detailed diagram shows the electrical implementation of each function of the PCB.
With the schematic drawn, a realistic drawing of the final PCB dimensions should be completed with areas designated for each of the circuit’s schematic blocks (groups of components closely connected for electrical reasons or constraints). Then the circuit is routed after placing the components according to the dimension of the board specified in the specifications.

A KiCAD routed Layout

A great beginner friendly course on PCB design is offered by TechExplorations on Udemy —

And a course for you skill upgrade from an OpenSource software(KiCAD) to Industry grade software (Altium) taught by David Ansel.

All the courses mentioned above + practice and learning time involved in doing them will take you around 6 months (including 8051).

Now is time to get back on track with your ARM Cortex-M based learning journey and start making use of HAL (Hardware abstraction layer) libraries for a variety of purposes.
Once you have an understanding of how to use them to cater your needs, you can try switching your project to LL Libraries — STM32 Low Level (LL) library is a relatively new library for programming the STM32 series.
The LL library offers a fast light-weight expert-oriented layer which is closer to hardware than the Hardware Abstraction Layer (HAL) library.
You can create your project based on HAL or LL from the CubeMX software itself (STM32CubeIDE nowadays).

And while you are at it, you can also explore a bit older but still useful Standard peripheral libraries
The STM32Fxx Standard Peripheral Library covers 3 abstraction levels, and includes:
1. A complete register address mapping with all bits, bit-fields and registers declared in C. This avoids a cumbersome task and more important, it brings the benefits of a bug free reference mapping file, speeding up the early project phase.
2. A collection of routines and data structures covering all peripheral functions (drivers with common API). It can directly be used as a reference framework, since it also includes macros for supporting core-related intrinsic features, common constants, and definition of data types.
3. A set of examples covering all available peripherals with template projects for the most common development tools. With the appropriate hardware evaluation board, this allows to get started with a brand-new micro within few hours.

Check it out here — Standard peripheral Library

Now is also a good time to explore the Timer peripherals of your Microcontroller & put them to a variety of uses.
Also play around with P.W.M and Low-Power mode of the MCU (If available).

Since you already have knowledge about various communication protocols like I2C, SPI, USART etc. Why not do some projects based on sensor interfacing?
Here is a youtube channel — MyAqoobEMbedded that will walk you through on interfacing sensors and other devices with your Micro-controller.
Remember, watch the video, learn from it and implement with your own features — For example, in one of his videos he teaches interfacing a MPU6050 with his MCU, you should understand how he does this and interface some other member of the family, like an MPU9250 and give your driver file additional features like Tilt detection etc.

If you require a more in-depth, hands-on training in interfacing sensors with your MCU, try this course by MakerMax, The explanations of concepts are crisp & clear.

Now is a great time to undertake a project for yourself. Which includes most of the things that you have learnt. For example:
1. A self balancing robot.
2. An obstacle avoiding robot.
3. Automatic traffic light controller/Parking system

The options are endless, and you must do a project now because it is very important to implement what ever you have gathered till now.

This post was PART-1 of a 3 part series.

In PART-2, I will be getting you acquainted to working with freeRTOS and DMA.

In PART-3 Embedded Linux & Bootloader (In-application programming) will be covered.

These posts are primarily focused on giving a clear learning path to embedded enthusiasts, I also host a timed questionnaire on Udemy wherein all of the above mentioned topics are given in a test format so that once you have started learning them, you can test your knowledge alongside for interview preparation.

--

--

Ajay Rajan

Writes about: Embedded-systems, Philosophy, Physics, Math, Neuroscience, Chess & Nihilism