In this article I will cover various aspects of microcontroller components, programming, interfacing peripherals, design, develop software, testing and debugging the developed software features.
Learn to develop software solutions for linux environment, implement requirements through real time projects and get required practical skills for software jobs
Learn firmware development theory, applications, get practical skills from online tests, projects and earn certificate for software jobs
An embedded system is a combination of computer hardware, software and few additional mechanical or electronic parts designed to perform a dedicated function. Examples of embedded systems are microwave oven, MP3 player, or alarm clock. microcontroller production counts are in the billions per year, and are integrated into household appliances (microwave, washing machine, coffee machine, . . . ) telecommunication (mobile phones), automotive industry (fuel injection, ABS, . . . ), aerospace industry, industrial automation and so on...
A personal computer too is comprised of computer hardware and software and mechanical components like memory cards, disk drives etc. But personal computer is not designed to perform a specific function. It does many different things for you starting from playing games to talking with friends over voice and video.
A personal computer uses a microprocessor where as an embedded system uses a microcontroller.
Since there is a wide variety of microcontrollers to choose from and since costs are important we need to select the cheapest device that matches the application’s needs.
The basic layout of a microcontroller is shown below. We will discuss each of the component and its interfacing with the microcontroller in great detail in the following sections.
CPU – Microcontrollers brain is named as CPU. CPU is the device which is employed to fetch data, decode it and at the end complete the assigned task successfully. With the help of CPU all the components of microcontroller is connected into a single system. Instruction fetched by the programmable memory is decoded by the CPU. CPU is a unit which monitors and controls all processes within the microcontroller and the user cannot affect its work. With the help of CPU all the components of microcontroller is connected into a single system. It consists of several smaller subunits, of which the most important are:
The instruction set is an important characteristic of any CPU. It influences the code size, that is, how much memory space your program takes. Hence, you should choose the controller whose instruction set best fits your specific needs.
Semiconductor memories can be broadly divided into volatile and non-volatile. This is shown in the following picture. Volatile memory retains its contents only so long as the system is powered on. Non-volatile memory retains its contents accross power cycles.
Embedded software development requires close interaction with the physical world—the hardware platform. In some cases there are very large embedded systems that require individuals to work solely on the application-layer software for the system. These application developers typically do not have any interaction with the hardware. When designed properly, the hardware device drivers are abstracted away from the actual hardware so that a developer writing software at the application level doesn't know how a string gets output to the display, just that it happens when a particular routine is called with the proper parameters.
Once components are selected project, next important step is to go through the specifications and write some initialization software. Whatever programming language is selected for a given project, it is important to institute some basic coding guidelines or styles to be followed by all developers on a project. Coding guidelines can make reading code easier, both for you and for the next developer that has to inherit your code.
Use the required IDE and compiler that is recommended for the microcontroller to compile the project.
After a program has been compiled and linked, you need to download the executable to the microcontroller.
Hardware can be classified as input or output. Inputs range from simple switches to complex analog sensors which measure physical values and convert them into a corresponding voltage. Outputs range from LEDs to actuators.
A button is one of the simplest input elements. It consists of two contacts which are connected if the button is pressed. So if one of the contacts is connected to for example GND and the other is connected to the microcontroller input, then the controller will read HIGH as long as the button is not pressed, and will read LOW while the button is pressed.
A switch works on the same principle like button. However, a switch remains in the position it is put. So if the switch is put into its ON position (which connects the contacts), then it will stay on until it is moved into the OFF position.
For practical applications of a push button switch, go to project switch interfacing with pic microcontroller.
The LED (light emitting diode) is the most basic output element. Its form and color vary widely to accommodate a wide variety of applications. The color of a LED is determined by the chemicals used for it. Common colors are red and green, but yellow, orange, blue and white LEDs are also readily available, as well as LEDs emitting light in the infrared or ultraviolet bands.
Most microcontrollers provide one or more timers with 8 and/or 16 bit resolution. Timers are used for a variety of tasks ranging from simple delays over measurement of periods to waveform generation.
The most basic use of the timer is in its function as a counter, but timers generally also allow the user to timestamp external events, to trigger interrupts after a certain number of clock cycles, and even to generate pulse-width modulated signals for motor control.
Pulse width Modulation or PWM is one of the powerful techniques used in control systems today. It is used in wide range of application which includes: speed control, power control, measurement and communication.
For detailed explanation about PWM theory of operation visit the article what is pwm and how it works.
For practical applications of pulse width modulation, go to project led brightness control using pwm with pic microcontroller.
A watchdog timer is a special hardware fail-safe mechanism that intervenes if the software stops functioning properly. The watchdog timer is periodically reset (sometimes called "kicking the dog") by software. If the software crashes or hangs, the watchdog timer soon expires, causing the entire system to be reset automatically.
The inclusion and use of a watchdog timer is a common way to deal with unexpected software hangs or crashes that may occur after the system is deployed.
Microcontrollers are meant to be deployed in systems that have to react to events. To monitor the events we can simply poll the input signal, that is, to periodically check for state changes. Polling has its drawbacks: Not only does it unnecessarily waste processor time if the event only occurs infrequently, it is also hard to modify or extend. After all, a microcontroller generally has a lot more to do than just wait for a single event.
The microcontroller itself offers a convenient way in the form of interrupts. Here, the microcontroller polls the signal and interrupts the main program only if a state change is detected. As long as there is no state change, the main program simply executes without any concerns about the event. As soon as the event occurs, the microcontroller calls an interrupt service routine (ISR) which handles the event. The ISR must be provided by the application programmer.
|Microcontroller fundamentals in a nutshell|
|How UART protocol works?|
|I2C programming in embedded C|
|SPI protocol theory of operation|
|Embedded c programming novice to professional in 24 hours|
|Storage classes in C|
|C standard library function fgets with example|
|C programming compiler errors warnings debugging|
|strcpy strncpy in c example illustration|
|C programming debugging exercises assignments solutions|
|Data types in C with examples|
|State machine implementation in C example|
|Functions in C examples|
|How to write makefile in linux for c|
|Strings in C examples|
|Pointers in C examples|
|Memory layout of C program in linux|
|Structure in C|
|Bit fields in C|
|Arrays in C|
|strcat, strncat, strcmp, strncmp, strchr, strrchr library functions|
|C control flow loops macros operators examples|
|Linux os concepts internals applications in a nutshell|
|Linux important commands illustrations examples|
|Shared library development with gcc in linux|
|Writing practical makefiles linux examples illustrations|
|Process practical applications illustration in linux|
|pthreads practical applications illustration in linux|
|Process in Linux|
|Search more C examples|
|Search more C MCQs|
|Linux software development|
|C programming & applications|
|Embedded systems development|
|Functions and its practical applications|
|Variables, Variables scope, Datatypes|
|Control flow, loops, operators, Macros|
|Arrays, Two dimensional arrays|
|Strings and its practical applications|
|Pointers and its practical applications|
|Structure, Unions, practical applications|
|Enums, Bit fiddling, practical applications|
|Data structures, practical applications|
|Python Data Type: Numbers & Applications|
|Python Data Type: Strings & Applications|
|Python Data Type: Lists & Applications|
|Python Data Type: Dictionary & Applications|
|Python Data Type: Tuples, Files & Applications|
|Python Data Type: Objects, Classes & Applications|
|Linux OS Internals|
|Linux OS Commands|
|Linux Processes and Threads|
|Linux IPC Mechanisms|
|Git Version Control|
|LCM and HCF of numbers|
|Time and Distance|
|Microcontrollers, Tools & Peripherals|
|I2C Protocol & Applications|
|SPI Protocol & Applications|
|UART Protocol & Applications|