Chapter 4: Inside The Embedded System, Number System, and AVR

In our previous article at We Observed, we deal with the few of the basics and important topics of an embedded system like Robotics, Microcontroller and microprocessor and brain behind the embedded system. Now we are moving to an embedded system. In which we will talk about, What is Embedded System and what is the importance of the embedded system? We will also talk about What makes it so useful that everyone is using this. So let’s start with the digital section of the embedded system.

Inside The Embedded System, Number System, and AVR

What Is Inside Embedded System?

Embedded System: An embedded system is a controller programmed and controlled by a real-time operating system (RTOS) with a dedicated function within a larger mechanical or electrical system, often with real-time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts.

As today everything is going digital. But do you know how it works? The answer to this question is the digital signal works only on two states i.e. ‘0’ & ‘1’. But what are these logic levels? Basically, these are the voltage level denotes high and low i.e. for low voltage level ‘0’ will be shown while for the high voltage level ‘1’ will be used.

High (1) and low (0) are actually the reference voltage level which is ideally taken as 2.5v. so when the 2.5 will flow in the compnent/ circuit, it will be indicated as “1”, and if Not ” State will be “0”.

Basic Parts of Embedded System


A register is simply a collection of some bits. Either each different bit in a register has some purpose or the register as a whole holds a value. Register serves as the connection between a CPU and a peripheral device (like ADC or TIMER).

Binary In ‘C’

When we write i=101; in C it means you are setting the value of variables “i” to one hundred one (decimal). Many times in programming (embedded) we are interested in the state of each bit in the variable.

Like when we write the bit register (ARPIT) to a bit pattern like 10011100 then we can’t write ARPIT=10011100 because the compiler will interpret it as a decimal. To make it binary in C program we have to prefix it with 0b. So if we want to assign a value in any variable in the embedded system we have to prefix it with 0b. Like


It assigns the bit pattern 10011100  to the bit of register ARPIT.

HEX In ‘C’

In the above program if we write 0xin place of 0b then the whole digit are in hexadecimal i.e.        0b10011100  in binary while in hexadecimal it is 0x10011100.

This is the difference in the binary and hexadecimal in the embedded system.

Setting a BIT in Register

In this our aim is to set (set ti logical 1) any given bit (let bit 5) of a given register. The Syntax is


ARPIT=ARPIT |  0b10011100

The above code will SET bit 5 to 1 leaving all other bits unchanged. Also the above code can be written as ” ARPIT |=0b10011100″

Now as per the practical purpose each bit got their name according to their work/ function. Let bit 5 has got the name to enable when we set it to 1 it enables the peripheral and when cleared, it disable it. So the right way to set is.


The “<<” is called left shift operator. It shifts the bits of LHS variable left by amount on it’s RHS variable. For ex: if we write c=1<<3, then the binary value of 1 i.e. 00000001 is shifted 3 places to the left which results in 00001000.

Clearing a BIT in Register

For clearing a bit logical AND (&) operator is used in place of logical OR (symbol |).

The syntax is as follows:


This will clear given the bit in a register called ARPIT. This operation will not affect any other bits of register except ENABLE.

Number System in Digital Electronics

The notation of the number in Binary and Hexadecimal is given below.

  • For Binary: ‘0’ and ‘1’ is use
  • For Hexadecimal: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

Number System in Digital Electronics

Note: We will use these hexadecimal codes in the coding part, To tell the position to the controller. 

Introduction to AVR Programming

As we discussed in our previous chapter that the embedded system is basically a combination of hardware and software. The “term” combination means (here) is that software is buried inside the hardware to perform the specific task automatically.

AVR Studio Inside The Embedded System, Number System, and AVR
AVR Studio

For performing different task on the computer, a compiler is the communication medium. As in C language, the compiler translates the source language into a target language. The compiler allows the user to perform the customized task on the machine. For writing compiler machine language is used. After some development assembly language and these days, a high-level language is used for writing compiler.

In the programming, we need a compiler because it is a medium that translates source language into the target language. The compiler allows the user to perform the customized task on the machine. Initially for writing compiler machine language was used.

The binary language is also called machine language. Where there is only machine language then programmers write their compilers in this language. But it is a very difficult and hard job. The role of the compiler is to take source code written in high-level language. So compiler converts the program written in the formal language into machine language.

Therefore programming is very much essential for an embedded system. Now, as we know there are so many languages and software are available for programming. So here we will be doing programming in embedded C. The term embedded C is given because it has some logic from C and some from C++. The compiler which is used the name as AVR GCC compiler. The compiler compiles codes and some other files also generate, in those files there will be a HEX file as we know that microcontroller understand only 0 and 1 logic only so this hex code will be helpful for burning our program in our hardware.

AVR Studio (Advanced Virtual RISC)

AVR Studio is a software created by Atmel in order to help developers to create an application for AVR microcontroller using C/ C++ programming languages. The program stands as a complete pack for programmers that use c++ and other programming languages.

The advantage of software is that there is no need to import any make file for each project, whenever click on build all option then it’ll run and compile the program automatically.

Working of the Process of Embedded C Projects

  • Write the program in AVR Studio
  • Compile them using AVR-GCC compiler
  • simulate the target AVR program
  • Program the actual chip using the USBASP USB device, which is attached to our target board with a special 6-pin cable.
  • Once programmed, the chip runs the program in our circuits.

In this article, we provided a detailed introduction to the embedded system along with the basic parts of the embedded system. The above steps will help to run code in software and for the detailed version of the code we are providing here the video, you can see this video to check how to compile/ run code in the software. That’s all for this chapter next we will deal with the detailed concept of AVR Studio in detail.

If you have any query feel free to contact us using the comment box given below. Our team will provide you the answer of your queries.


About The Boss

The Boss (Code Name) is living in Jaipur. He Completed B.Tech with EC Branch. He Also completed various courses Related to Robotics, Embedded System and Automation. He is Currently working as Content Writer but he is also active in Making Electronics Projects.

View all posts by The Boss →

Leave a Reply

Your email address will not be published. Required fields are marked *