Microcontrollers for beginners (A perfect Introduction)

At the beginning when I was starting with microcontrollers, when I searched the term “microcontrollers for beginners” or “introduction to microcontrollers” there I found tons of articles which describes a microcontroller and start programming it. But I suggest when beginning with any subject/field its a good idea to lay a strong foundation by knowing exactly what you are going to do, which areas you are going to cover. Briefly, what the subject is and in what a wide area is it spread.

After reading this article you should be able to understand,

  • what is a microcontroller and where to use it?
  • Get a clear view between microprocessor and microcontroller.
  • Basic understanding of processor architectures.
  • Get an idea about microcontroller manufacturers and brands.
  • Get an idea about the process of programming microcontrollers.

Well, If you are an absolute beginner to this subject I would like to say that you are in the correct place, to begin with. Here in this article, we will not start writing any codes or using any tools. But if you wish you can skip this and go to our next article,

  •  Microcontrollers for beginners – The fundamentals (link will be available soon)

If you are a beginner to the subject “automation”, here is our tutorial which discusses the major automation techniques/methods. – Introduction to robotics and automation

What is a microcontroller? – Introduction to microcontrollers.

The shortest answer is “microcontroller is a small computer consist of a CPU, RAM, ROM and other initial peripherals such as EEPROM, A/D converters, and the ability to handle basic I/O”

You can find microcontrollers in almost every digital electronic application such as cameras, mobile phones, TVs, automobiles, remote controllers, toys, etc. Microcontrollers are used in a wide range of applications starting from a simple timer circuit up to a highly automated self-navigated missile system.

As its name pronounce, “micro + controller”,  it’s a tiny controller device which acts as a brain to automate or control a process/system. As an electrical guy, you may be already knowing about other control methods such as hardwired control units. So first, let’s see which kind of a role does microcontrollers play among them.


Why microcontrollers?

Suppose you are given to design a control system for an elevator of a two story building. Since it’s just for two floors the logic is simple, So if you are an electrical guy you will design a hardwired control circuit with timers, relays and logic gates. Now if the number of floors increases up to 10 floors,  just imagine how to design one, can you? even an expert electrical engineer will feel uncomfortable in designing a hardwired control in such case. Now it isn’t simple because there are a number of factors to consider such as safety features, methods to handle multiple requests (On such occasions which request to serve first), etc. It’s extremely difficult to handle such complex system with hard-wired control designs. Ok, let’s assume you did it somehow using thousands of relays, timers and logic gates. Now, what may happen if a bug is found or an update is required to the system. You will have to change the entire control circuit with thousands of connections. It will take months or probably years to complete. In such systems debugging and updating will be a real mess.

   This is the point where microcontrollers come into action. All the inputs such as limit switches, push buttons will be given to the microcontroller’s input pins. Then all the outputs (such as motors, alarms, servos) will be set to drive via microcontroller’s output pins. Now comes the most important event in the process, giving the operational logic to the microcontroller. This is the process which is known as programming the microcontroller. Once programming the microcontroller and powering it, then it operates according to the uploaded program. Something which sounds like, observes the inputs and control the outputs according to the program(given logic).

  Now again comes the above question, “What to do if a bug is found or update is needed?”.  Well, if you find a bug or needed to change the operational logic, simply write the new program and upload it to the microcontroller. No need of touching a single electronic part. As well as, suppose a floor was newly added to the building, now it requires a system update. In this case, give the new inputs (switches/limit switches) to the microcontroller via input pins and upload the new program for it to operate. It’s that simple with microcontrollers.


Microcontrollers vs. microprocessors

Both sounds like they are similar but, they are two terms that you should clearly understand.

Microprocessors consist of only the CPU/processor. All the other essential peripherals such as RAM, ROM, EEPROM, I/O should be externally connected to the microprocessor in order to get a functioning system. So, to use microprocessors it requires much advance electronic/hardware designs and also advances electronic knowledge. Since it requires advance designs and separate components, implementing microprocessors are usually costly. Most probably microprocessors operate at higher frequencies. So they are more suitable for applications which require a higher processing power such as PCs, PLCs and AI systems. And also in applications where it requires more hardware customization. There are several microprocessor manufacturers and some of the leading among them are Intel, ARM, Nvidia, AMD. etc. 


structure of a microcontroller

As the above image demonstrate microcontrollers consist of all the required components and optional components such as RAM, ROM, EEPROM, A/D converters, timers, CCP modules and I/O capabilities, all built into a single chip. As said in the beginning it is a tiny computer on a chip. This makes microcontrollers easy to be used in embed systems and also to be cost efficient. What makes it different from a regular computer is that microcontrollers are application specific which is designed to run a single application only. So microcontrollers are widely used in small to medium sized automated/ intelligent applications, such as home automated systems, remote controllers, industry automation controllers… etc. 

Now as a beginner you may be curious about whether to use microprocessors or microcontrollers and what are the differences between them in embedded engineering. Well, as described above microprocessors are more customizable and have more processing power usually than microcontrollers does. They run at higher clock speeds which enable it to deliver a higher processing power. Its program memory is able to expand as needed, in order to run larger programs.  But in embedded engineering, I have never seen microprocessor based designs are used. That’s because microcontrollers are more than enough for what we need in such applications. Even there are microcontrollers capable of running complex codes such as image processing algorithms or Linux applications, That’s cool. So it’s up to you the developer, to select the correct microcontroller for your project.

Understand the processor architecture

The function of a microprocessor is an extremely complex process. Here we need not dig into the deep end of a processor and its internal structure. So simply let’s consider that a CPU processes data by transferring the data from the RAM to the ALU and vice versa, through the data bus. It can transfer an amount of data at a time that equals to the width of the data bus. Usually, the width of the data bus will match the width of the registers in the CPU. This number will look something like 4-bit, 8-bit, 16-bit, 32-bit and 64-bit. The higher this number the processing power is considered high. In these processors, the specific method which they use to process the data is called as the processor architecture or core. It may be a company/manufacturer specific architecture or an architecture that is licensed by another vendor.

Well, read this paragraph just to get a rough idea about processor architectures. For a beginner, its no need to think it much, just keep on reading to get a rough idea. Intel processors use their own core x86 for 32-bit processors and x64 for 64-bit processors, and only Intel uses these cores. The 8051 architecture was developed by Intel for 8-bit processors and many microcontroller manufacturers use it for their 8-bit devices.

A UK based company called “ARM” developed a processor architecture called ARM architecture for 32-bit processors, and ARM64 for 64-bit processors which is considered as a highly successful core. And they license it to other manufacturers, which is a great start for embed electronics systems since microcontroller manufacturers start producing ARM-based microcontrollers which deliver a high processing power with an optimized core under low power consumptions. The leading smartphone CPU manufacturer “Qualcomm” also uses the ARM Cortex cores.

Microcontrollers come in 8-bit, 16-bit and 32 -bit instructions. Out of these most probably 32bit chips comes with the ARM core. However, on some occasions, they use their own architectures also. Microprocessors are usually manufactured in 32-bit and 64-bit only nowadays. From the viewpoint of a programmer If you are coding in assembler, you have to care about the instruction width and change the code depending on it. If you use a high-level language such as c/c++ then you need not worry about the instruction set as the compiler will handle all the hard work. You write the code once and compile it to a specific chip, it works. But you should have the knowledge to select the most suitable chip by considering which kind of calculations will take place. We will discuss it in a separate article later.


Something more about microcontrollers

After reading the above article if someone tries to get an idea, that you should always use microprocessors as they are much powerful than microcontrollers, that’s completely a wrong idea. It doesn’t mean that microcontrollers are less effective and cannot do things like a microprocessor does. It depends on the application, and there are places where microcontrollers are more suitable than microprocessors. In some complex designs, it can be found microprocessors and microcontrollers are used at the same time by communicating between each other.

  Microcontroller manufacturers now focus on manufacturing high-end microcontrollers including various kind of useful features such as,

  • Ultra-low power consumption
  • NFC capabilities
  • Hardware encryption capabilities for security based applications.
  • Capacitive touch capabilities.
  • CAN/VAN networking capabilities. And much more.

The following features bring microcontrollers ahead of microprocessors.

  • Low cost.
  • Occupies little space.
  • Easy to design and implement in projects.
  • Fast production (Can bring an innovative idea to the market as a product in a short time)


What is a SoC chip?

While reading this article did you wonder what chip, microcontroller or microprocessor is used in your mobile phone? Well, they use a type of chip which is called a SoC. SoC refers to System On Chip, a chip that includes all the peripherals that are required for a particular system. So companies manufacture SoCs by targeting on specific systems such as smart phones, military devices or automobiles. A SoC chip may include a microcontroller(or microprocessor), analog, digital, radio frequency functions, Wi-Fi functions, Gps, accelerometer and gyro functions and even a GPU, all in a single chip. Devices such as wearable computers and smartphones use SoC chips instead of building their own circuits. Companies such as Samsung, Intel, Qualcomm, manufactures high-end SoC chips. You can read more about SoC s from here.


microcontroller brands.

microcontroller brands

There are plenty of microcontroller manufacturers who produces microcontrollers with a nice set of balanced features and attractive prices. Here are some brands which are widely used in industries and among hobbyists. 

  • Texas Instruments (TI) – Is an American semiconductor company designs and manufacture a large number of semiconductor products including microcontrollers. They have a good community support and clear documentations. And there are plenty of resources.
  • STMicroelectronics(ST) –  Is an electronic and semiconductor manufacturer, in Switzerland. Based on revenue ST is the largest semiconductor manufacturer in Europe. STs microcontrollers are also widely used and have a good community support and well documented.
  • Microchip – Is an American semiconductor manufacturer. Specially focused on microcontrollers, microprocessors, memories and analog chips. Microchip’s PIC series is very popular among hobbyists and widely used in embed applications. Has a good community support.
  • Atmel – Is also an American semiconductor manufacturer who focus on manufacturing microcontrollers and embedded applications. Atmel microcontrollers are very popular among students and hobbyists due to “Arduino“, which is an open-source electronic prototyping platform based on Atmel microcontrollers. They also provide a free development platform “Atmel Studio”, which can be used to program any of their MCUs. The Microchip company bought Atmel for $3.56 Billion in 2016.
  • NXP – NXP is a leading semiconductor manufacturer in Netherlands, which is the combination of Philips Semiconductors and Freescale semiconductors. Also, It is the leading semiconductor manufacturer for the automobile industry. They have a large number of feature rich microcontrollers, but not so popular among hobbyists and beginners, due to low community support. Their documentations are nice but require some prior knowledge about microcontrollers to understand. In 2016 Qualcomm announced that they would buy NXP.
  • Intel microcontrollers – Intel produces their 32-bit Quark microcontrollers which run on their own x86 core. Most hobbyists even don’t know that Intel produces microcontrollers, but they do. You can refer it on their official page here.
  • Infineon – Is a German semiconductor manufacturer.
  • Renesas – Is a japenese semiconductor manufacturer.

As a beginner now you may be wondering which is the best brand out of these. Who produces the most reliable and robust devices. Unfortunately, no one can answer that question. All are competitive and roughly in the same price range. So if one brand is better no one would buy the others. Always they try to introduce a new device with new features to stay in the competition. So in the process of learning it is an important part to play with many devices in several brands. Then discuss them in online forms with others. So that you will gather a lot of knowledge by sharing yours too, that’s cool.


Understanding the programming process.

As an absolute beginner to the subject, you may be curious about how the programming process looks like. Certainly, that’s the most interesting part for a newcomer. So I’ll briefly demonstrate it here. 


Step 1

Write the program in the appropriate language(Assembly, C/C++ or any other) using the specific tools and software.  According to the developer’s preference, it is able to use 3rd party supplied tools or the tools supplied by the chip manufacturer.

Step 2

programming microcontroller-step 2

Compile the program and create the .hex file. It is the file, containing the program/instructions in the machine language which the microcontrollers processor understands.

Step 3

programming microcontroller-step 3

Upload the above created .hex file to the microcontroller using the appropriate hardware. For this step, you have to use a special hardware called a “microcontroller programmer” (This can be a manufacturer provided device or a device provided by a third-party). Connect it to the computer via USB or serial port, and the other ends to the appropriate pins of the microcontroller (According to the data sheet). Then use the chip programmers specific software to select the .hex file and upload it. The software, the programmer and the microcontroller will communicate and write the .hex file to the microcontroller’s ROM memory. When it’s done then disconnect the chip.

Step 4

programming microcontroller-step 4

Now you have a programmed microcontroller. Place it on the target hardware and power it. Now the Microcontroller will work independently by controlling the device according to the uploaded program. It’s the microcontroller in action in the real world.

NOTE: It is not compulsory to always remove the microcontroller from the target application to change its program. There are methods to program the microcontroller while it is on the circuit. (By using bootloaders or in circuit serial programmers.)


Conclusion and The final words

As in the topic of this article “Microcontrollers for beginners”, I wrote the article, keeping the contents focused to beginners In order to give a perfect Introduction to the subject. Here we didn’t write a line of code either designed any electronic circuits. All we did here is discussed the surrounding areas of the subject in order to have an idea what we are going to learn in the future articles.

If you are wondering where to start and what is the best chip, to begin with, It’s a good idea to start from an 8-bit device and then shift to 32-bit AVR based microcontrollers, which has a good community support. However, this website will provide you with all the resources, the required knowledge, and guidance. Stay connected with us, Don’t miss any valuable article, please subscribe to our newsletter.

If you found this tutorial interesting or have any questions please drop a comment below. I highly appreciate all suggestions and ideas.

Sharing is caring!

Lakshitha Dias

Yes I'm Lakshitha Dias from Sri Lanka, who is interested in digital electronics, microcontroller technology, and computer science.

Stay connected with me

Leave a Reply

1 Comment on "Microcontrollers for beginners (A perfect Introduction)"

Notify of
Sort by:   newest | oldest | most voted

Sinhalen dammanam godak hodai 🙂 Nice article