microcontroller is a small and low-cost microcomputer, which is designed to perform the specific tasks of embedded systems like displaying microwave’s information, receiving remote signals, etc.

The general microcontroller consists of the processor, the memory (RAM, ROM, EPROM), Serial ports, peripherals (timers, counters), etc.




Based on the memory configuration, the microcontroller is further divided into two categories.

  • External memory microcontroller– This type of microcontroller is designed in such a way that they do not have a program memory on the chip. Hence, it is named as external memory microcontroller. For example: Intel 8031 microcontroller.
  • Embedded memory microcontroller− This type of microcontroller is designed in such a way that the microcontroller has all programs and data memory, counters and timers, interrupts, I/O ports are embedded on the chip. For example: Intel 8051 microcontroller.



The timer is an important application in embedded systems, it maintains the timing of an operation in sync with a system clock or an external clock. The timer has so many applications such as measure time generating delays, they can also be used for generating baud rates.
A normal delay function might be used for loop iterating for a few 1000 cycles. But these types of delays need not be accurate and fundamentally it is not a good programming practice. So, TIMER/COUNTER is a software designed to count the time interval between events. It counts the cycle of the peripheral clock or an externally supplied clock.

Timer T0 & T1

Timers T0 and T1 completely fall under the 8051 Standard. They are 16 bit wide as shown. This can be accessed as two 8-bit registers THx and TLx, representing a low and a high byte of 16-bit register.

Arithmetic and logic unit

Inside a computer, there is an Arithmetic Logic Unit (ALU), which is capable of performing logical operations (e.g. AND, OR, Ex-OR, Invert etc.) in addition to the arithmetic operations (e.g. Addition, Subtraction etc.). The control unit supplies the data required by the ALU from memory, or from input devices, and directs the ALU to perform a specific operation based on the instruction fetched from the memory. ALU is the “calculator” portion of the computer.

An arithmetic logic unit (ALU) is a major component of the central processing unit of the a computer system. It does all processes related to arithmetic and logic operations that need to be done on instruction words. In some microprocessor architectures, the ALU is divided into the arithmetic unit (AU) and the logic unit (LU).

An ALU can be designed by engineers to calculate many different operations. When the operations become more and more complex, then the ALU will also become more and more expensive and also takes up more space in the CPU and dissipates more heat. That is why engineers make the ALU powerful enough to ensure that the CPU is also powerful and fast, but not so complex as to become prohibitive in terms of cost and other disadvantages.

ALU is also known as an Integer Unit (IU). The arithmetic logic unit is that part of the CPU that handles all the calculations the CPU may need. Most of these operations are logical in nature. Depending on how the ALU is designed, it can make the CPU more powerful, but it also consumes more energy and creates more heat. Therefore, there must be a balance between how powerful and complex the ALU is and how expensive the whole unit becomes. This is why faster CPUs are more expensive, consume more power and dissipate more heat.

Different operation as carried out by ALU can be categorized as follows –

  • Logical operations: These include operations like AND, OR, NOT, XOR, NOR, NAND, etc.
  • Bit-Shifting Operations: This pertains to shifting the positions of the bits by a certain number of places either towards the right or left, which is considered a multiplication or division operations.
  • Arithmetic operations: This refers to bit addition and subtraction. Although multiplication and division are sometimes used, these operations are more expensive to make. Multiplication and subtraction can also be done by repetitive additions and subtractions respectively.


Analog to digital convertor

Analog to digital converters are very essential because, as these systems deal with digital values, their surrounds usually involve various analog signals. These signals need to be changed into digital before being treated by the microcontroller and the most important specification of analog to digital converter is the resolution. It specifies how exactly the ADC measures the analog input signals. The common ADC’s available in the market are 8-bit, 10-bit and 12-bit. The other specification of the ADC is the sampling rate, it specifies how fast the A/D converter can take readings. n an embedded system, A/D conversion is very important as embedded systems deal with digital values; their surroundings usually occupy various analog signals. Analog signals need to be altered into digital before being treated by the microcontroller. At present, we can observe how to read an external analog signal using PIC microcontroller and exhibit the digital o/p conversion on an LCD display. The input signal can be a varying voltage between 0 to 5v.

The most important requirement of analog to digital conversion is the resolution. This states how exactly the A/D conversion measures the analog i/p signals. The common A/D conversions available in the market are 8-bit, 10-bit &12-bit. For example, if the reference voltage of A/D conversion is 0-5V, then a 8-bit A/D converter breaks this voltage into a number of parts (256 parts). So it can calculate the voltage exactly up to 5/256v= 19 mV approx. On the other hand, a 10-bit A/D converter breaks the voltage into 1024 parts. And hence, this converter can calculate the voltage accurately up to 5/1024= 4.8mV approx. Therefore, you can notice that the 8-bit A/D converter cannot tell the difference between 1mV & 18mV.

Input and output lines

  • Pin configuration, i.e. the pin can be configured as 1 for input and 0 for output as per the logic state.
    • Input/output (I/O) pin− All the circuits within the microcontroller must be connected to one of its pins except P0 port because it does not have pull-up resistors built-in.
    • Input pin− Logic 1 is applied to a bit of the P register. The output FE transistor is turned off and the other pin remains connected to the power supply voltage over a pull-up resistor of high resistance.
  • Port 0− The P0 (zero) port is characterized by two functions −
    • When the external memory is used then the lower address byte (addresses A0A7) is applied on it, else all bits of this port are configured as input/output.
    • When P0 port is configured as an output then other ports consisting of pins with built-in pull-up resistor connected by its end to 5V power supply, the pins of this port have this resistor left out.

Input Configuration

If any pin of this port is configured as an input, then it acts as if it “floats”, i.e. the input has unlimited input resistance and in-determined potential.

Output Configuration

When the pin is configured as an output, then it acts as an “open drain”. By applying logic 0 to a port bit, the appropriate pin will be connected to ground (0V), and applying logic 1, the external output will keep on “floating”.

In order to apply logic 1 (5V) on this output pin, it is necessary to build an external pull-up resistor.



Registers are used in the CPU to store information on temporarily basis which could be data to be processed, or an address pointing to the data which is to be fetched. In 8051, there is one data type is of 8-bits, from the MSB (most significant bit) D7 to the LSB (least significant bit) D0. With 8-bit data type, any data type larger than 8-bits must be broken into 8-bit chunks before it is processed.


The accumulator, register A, is used for all arithmetic and logic operations. If the accumulator is not present, then every result of each calculation (addition, multiplication, shift, etc.) is to be stored into the main memory. Access to main memory is slower than access to a register like the accumulator because the technology used for the large main memory is slower (but cheaper) than that used for a register.

The “R” Registers

The “R” registers are a set of eight registers, namely, R0, R1 to R7. These registers function as auxiliary or temporary storage registers in many operations. Consider an example of the sum of 10 and 20. Store a variable 10 in an accumulator and another variable 20 in, say, register R4. To process the addition operation, execute the following command −


After executing this instruction, the accumulator will contain the value 30. Thus “R” registers are very important auxiliary or helper registers. The Accumulator alone would not be very useful if it were not for these “R” registers. The “R” registers are meant for temporarily storage of values.

Let us take another example. We will add the values in R1 and R2 together and then subtract the values of R3 and R4 from the result.

The “B” Register

The “B” register is very similar to the Accumulator in the sense that it may hold an 8-bit (1-byte) value. The “B” register is used only by two 8051 instructions: MUL AB and DIV AB. To quickly and easily multiply or divide A by another number, you may store the other number in “B” and make use of these two instructions. Apart from using MUL and DIV instructions, the “B” register is often used as yet another temporary storage register, much like a ninth R register.

Coding the microcontroller –The Process


Assembly languages were developed to provide mnemonics or symbols for the machine level code instructions. Assembly language programs consist of mnemonics, thus they should be translated into machine code. A program that is responsible for this conversion is known as assembler. Assembly language is often termed as a low-level language because it directly works with the internal structure of the CPU. To program in assembly language, a programmer must know all the registers of the CPU.

Different programming languages such as C, C++, Java and various other languages are called high-level languages because they do not deal with the internal details of a CPU. In contrast, an assembler is used to translate an assembly language program into machine code (sometimes also called object code or opcode). Similarly, a compiler translates a high-level language into machine code. For example, to write a program in C language, one must use a C compiler to translate the program into machine language.


Process of Assembly Language/Coding

An assembly language program is a series of statements, which are either assembly language instructions such as ADD and MOV, or statements called directives.

An instruction tells the CPU what to do, while a directive (also called pseudo-instructions) gives instruction to the assembler. For example, ADD and MOV instructions are commands which the CPU runs, while ORG and END are assembler directives. The assembler places the opcode to the memory location 0 when the ORG directive is used, while END indicates to the end of the source code. A program language instruction consists of the following four fields −

[ label: ]   mnemonics  [ operands ]   [;comment ]

A square bracket ( [ ] ) indicates that the field is optional.

  • The label fieldallows the program to refer to a line of code by name. The label fields cannot exceed a certain number of characters.
  • The mnemonicsand operands fields together perform the real work of the program and accomplish the tasks. Statements like ADD A , C & MOV C, #68 where ADD and MOV are the mnemonics, which produce opcodes ; “A, C” and “C, #68” are operands. These two fields could contain directives. Directives do not generate machine code and are used only by the assembler, whereas instructions are translated into machine code for the CPU to execute.

1.0000         ORG  0H            ;start (origin) at location 0 2 0000 7D25    MOV  R5,#25H       ;load 25H into R5 3.0002 7F34    MOV  R7,#34H       ;load 34H into  R7 4.0004 7400    MOV  A,#0          ;load 0 into A 5.0006 2D      ADD  A,R5          ;add contents of R5 to A 6.0007 2F      ADD  A,R7          ;add contents of R7 to A7.0008 2412    ADD  A,#12H        ;add to A value 12 H 8.000A 80FE    HERE: SJMP HERE    ;stay in this loop 9.000C END                        ;end of asm source file

  • The comment fieldbegins with a semicolon which is a comment indicator.
  • Notice the Label “HERE” in the program. Any label which refers to an instruction should be followed by a colon.


Is there a strategy that can be applied to both IP-based and standard semiconductor products that will allow device users to control energy consumption in a manner that is simple and reliable, that will give the user full visibility into operation, and that can maintain safe and secure conditions? Improved results can come with an increased degree of control of operating modes.

No matter what the area of application, a key factor today in achieving market success with an electronic system is minimizing its energy demand. The traditional approach of expressing a component’s efficiency in terms of current or steady-state power – microAmperes (µA) or microWatts (µW) per MHz seems to not work anymore. Energy storage systems hold neither µA nor µW, they store “Joules” – in other words, energy. The latest generation of ultra-low-energy efficient MCUs follows a similar power management strategy to that of high performance processors; they use a DC/DC converter in combination with linear regulators.