You are on page 1of 21

Microcontrollers & Embedded Systems

Sudipta Mahapatra, Ph.D. Department of E & ECE IIT Kharagpur

Module-1 : Introduction to Computer Architecture and Microcontrollers

Number systems, overview of digital logic, basic computer organization, microcontroller features, microcontrollers vs. microprocessors.

Module-2 : The 8051 Microcontroller

Overview of 8051 family; Architecture of 8051; Programming model, Instruction set, Addressing modes; 8051 programming in C.

Module-3 : I/O Interfacing Module-4 : Interrupts and Timers Module-5 : Interfacing of peripherals to 8051 Module-6 : The ARM processor Module-7: Embedded Systems
Book: 1. The 8051 Microcontroller and Embedded Systems Using Assembly and C, Mazidi M. A.. 2. Microcontrollers Principles and Applications, Ajit Pal 3. Embedded System Design, Santanu Chattopadhyay

Mid-semester examination : 30 Marks End-semester examination : 50 marks Class Test N+1 class tests, randomly taken. Out of these best N marks will be considered in the final evaluation : 15 Marks. Attendance Will also be taken randomly Attendance marks=5-Number of classes missed. Grades?

Bits, Nibbles, Bytes Conventions define relationship between bits and numbers Binary numbers (base 2), Decimal numbers (base 10), Octal numbers (base ?), Hexadecimal numbers (base ?) Conversion - (323.12)4=(?)10 Negative numbers, how to represent them Compute 5510-4410 using binary arithmetic.


Binary logic and logic gates

Binary logic TTL Logic 0 0V to 0.8 V Logic 1 3V to 5 V Logic gates AND, OR, NOT, NAND, NOR, XOR, XNOR Tri-state buffer Flip-flops Half-Adder S=A B; C=A.B Full-Adder S=A B Cin , Cout=(A.B)+(Cin.(A B))

Adder Circuits
x y Cin HA HA Cout S


S0 S1 S2 S3 FA

X0 Y0 FA

X1 Y1 Carry FA

X2 Y2 Carry FA

Y3 Carry


4-bit adder

Basic Computer Organization

Address bus
Memory (ROM, RAM) Peripherals (I/O Devices)


Data bus

Internal Organization

Internal Organization (Contd.)

A simple example
A CPU has registers A, B, C, and D and it has an 8-bit data bus and a 16-bit address bus (the CPU can access memory from addresses 0000 to FFFFH) Assume that the code for the CPU to move a value to register A is B0H and the code for adding a value to register A is 04H. The action to be performed by the CPU is to put 21H into register A, and then add to register A values 42H and 12H to it.

Steps and Code

Action Move value 21H into reg. A Add value 42H to reg. A Add value 12H to reg. A Mem. addr. 1400 1401 1402 1403 1404 1405 1406 Code B0H 04H 04H Data 21H 42H 12H

Contents of memory address (B0) // code for moving a value to register A (21) // value to be moved (04) // code for adding a value to register A (42) // value to be added (04) // code for adding a value to register A (12) // value to be added (F4) // code for halt

CPU Actions
1. The program counter is set to the value 1400H, indicating the address of the first instruction code to be executed 2. The CPU puts 1400H on address bus and sends it out; the memory circuitry finds the location. 3. The CPU activates the READ signal, indicating to memory that it wants the byte at location 1400H; this causes the contents of memory location 1400H, which is B0, to be put on the data bus and brought into the CPU. 4. The CPU decodes the instruction B0 and commands its controller circuitry to bring into register A of the CPU the byte in the next memory location 5. The value 21H goes into register A; the program counter points to the address of the next instruction to be executed, which is 1402H, and address 1402 is sent out on the address bus to fetch the next instruction


6. Code 04H is fetched from memory location 1402H; after decoding, the CPU knows that it must add to the contents of register A the byte sitting at the next address (1403). 7. After the CPU brings the value (42H), it provides the contents of register A along with this value to the ALU to perform the addition. 8. It then takes the result of the addition from the ALUs output and puts it in register A; the program counter is incremented to 1404, the address of the next instruction.


Memory System


General processor microprocessors are used as the CPU in a computer system. In order to be useful these are to be interfaced with ROM, RAM and peripheral devices.


Microcontroller Features
On-chip oscillator Large number of Special-purpose registers. Harvard architecture On-chip program memory On-chip data memory On-chip I/O ports Watchdog timer


Microcontroller Features (Contd.)

Powerful Interrupt Structure - External Interrupt - Event Based Internal Interrupt; timer/counter, serial port - Exceptions Fast context switching through the use of register banks. Built-in ADC Built-in PWM


How to choose a microcontroller

ALU capability Number of bits it can process at a time;
4 bit: Hitachi HMCS40, National COP420, Toshiba TLCS47 8-bit: Intel 8048, 8051, National COP820, Zilog Z8, TI TMS370C050 16 -bit: Intel 80C196, HitachiH8/532, National HPC16164 32-bit: Intel i960, PIC32 produced by PIC@

Size of on-chip ROM, on-chip RAM Number of I/O ports/pins Number of on-chip timer/counter Availability of on-chip serial ports Availability of on-chip ADC Availability of on-chip PWM circuit Power consumption Unit cost


Ask Yourself
1. What are the different number systems? 2. How to convert one number system to another? 3. What are the different logic gates, tri-state buffers, flip-flops, Half-adder, and Full-adder. How to design digital circuits? 4. Basic computer organization and operation? 5. The memory system difference between RAM and ROM in terms of usage? 6. What are the main features of a microcontroller? 7. Can you name a few popular 8-bit, 16-bit, and 32-bit microcontrollers?


Typical Applications
Home Appliances Intercom, telephones, security systems, garage door openers, answering machines, fax machines, TVs, cable TV tuner, VCR, camcorder, remote controls, video games, cellular phones, musical instruments, sewing machines, lighting control, paging, camera, pinball machines, toys, exercise equipment Office Equipments Telephones, computers, security systems, fax machines, copier, laser printer. Automobiles Engine control, air bag, ABS, instrumentation, security system, transmission control, entertainment, climate control.


Lecture slides for The 8051 Microcontroller and Embedded Systems: Using Assembly and C by Mazidi, Mazidi and McKinlay

Chung-Ping Young, Home Automation, Networking, and Entertainment Lab Dept. of Computer Science and Information Engineering National Cheng Kung University, TAIWAN

Download Assembler for 8051