0% found this document useful (0 votes)
27 views27 pages

Introduction To Microcontroller

Studyyy

Uploaded by

Firuz Masuda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views27 pages

Introduction To Microcontroller

Studyyy

Uploaded by

Firuz Masuda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Introduction to Microcontrollers

Dr. Mohammad Mahbubur Rahman,


Assistant Professor, EEE
School of Science, Engineering and Technology (SoSET)
East Delta University

Dr. Mohammad Mahbubur Rahman


Microprocessor is a multipurpose, programmable register based electronic device which read binary
instructions from memory, processes the input data as per instructions and provides output.

RAM/Primary
memory or input
device

ROM Microprocessor

RAM/Primary
memory or output
device

2
Dr. Mohammad Mahbubur Rahman
Microcomputer is used to describe a system that includes a minimum of a microprocessor, program memory,
data memory, and input/output (I/O). Some microcomputer systems include additional components such as
timers, counters, analogue-to-digital converters and so on.

Input
RAM device

ROM Microprocessor

Output device

3
Dr. Mohammad Mahbubur Rahman
Microcontroller
• A smaller computer on a CHIP
• On-chip RAM, ROM, I/O Ports, Timer, Serial Controller…
• Example: Motorola’s 6811, Intel’s 8051, Atmel 32
Microprocessor vs. Microcontroller
Microprocessor Microcontroller
• CPU is stand-alone, RAM, • CPU, RAM, ROM, I/O and timer
ROM, I/O, timer are separate are all on a single chip

• Designer can decide on the • Fixed amount of on-chip ROM,


amount of ROM, RAM and I/O RAM, I/O ports
ports.
• Not Expansive
• Expansive
• Single-purpose
• Versatility
• Special Purpose.
• General-purpose
types of microcontrollers
• Embedded
– All the hardware required to run the application is
provided on the chip. typically: power, reset, clock,
memory and IO.
• External memory
– some microcontrollers allow the connection of external
memory.

Dr. Mohammad Mahbubur Rahman


Comparing µC with µP
• General-purpose
microprocessors contains
o No RAM
➢ Have the advantage of versatility on the
o No ROM
amount of RAM, ROM, and I/O ports
o No I/O ports
• Microcontroller has
o CPU (microprocessor)
o RAM
o ROM
➢ The fixed amount of on-chip ROM, RAM,
o I/O ports
and number of I/O ports and less
o Timer computing power; suitable for very
o ADC and other peripherals specific purpose with much less cost.

Dr. Mohammad Mahbubur Rahman


Applications

Dr. Mohammad Mahbubur Rahman


Examples of 8-bit µC
▪ Motorola’s 6811
▪ Intel’s 8051
▪ Zilog’s Z8
▪ Microchip’s PIC
The 8051 family has the largest number of
diversified (multiple source) suppliers:
o Intel (original)
o Atmel
o Philips/Signetics
o AMD
o Infineon (formerly Siemens)
o Matra
o Dallas Semiconductor/Maxim

Dr. Mohammad Mahbubur Rahman


Microcontroller is a device that includes microprocessor, memory and input/output devices on a single chip. Microcontroller has a CPU,
in addition with a fixed amount of RAM, ROM and other peripherals all embedded on a single chip. At times it is also termed as a mini
computer or a computer on a single chip.

Amicrocontroller consist following functional


units:
• Central Processing Unit
• Memory Unit
• System Bus
• Input/Output Port
• Serial Communication
• Timer Unit.
• Interrupt System.
• Watchdog
• Analog to Digital Converter
• Oscillator
• Program
1
Dr. Mohammad Mahbubur Rahman
0
• Central Processing Unit
• System Bus
Processor Bandwidth Processor Clock
• Memory Unit
• Input/Output Port • 8-bit
• Serial Communication • 16-bit Internal
• Timer Unit. Oscillator
• 32-bit Oscillator
• Interrupt System. External
• Watchdog Oscillator
• Analog to Digital Converter
8-bit processor having clock frequency 16
• Oscillator
MHz
• Program Processor can execute 4 × 106 instructions/sec where data is 8-bit long (0 to 255
1 or - 128 to +127)
Dr. Mohammad Mahbubur Rahman
1
• Central Processing Unit
• System Bus
• Memory Unit
• Input/Output Port
• Serial Communication
• Timer Unit.
• Interrupt System.
• Watchdog
• Analog to Digital Converter
• Oscillator
• Program

1
Dr. Mohammad Mahbubur Rahman
2
Read Only Memory (ROM)
• Central Processing Unit
Read Only Memory (ROM) is a type of memory used to permanently save the program being
• System Bus
executed.The size of the program that can be written depends on the size of this memory.
• Memory Unit
• Input/Output Port ROM is nonvolatile. It stores the program.
• Serial Communication
• Timer Unit. Random Access Memory (RAM)
• Interrupt System.
• Watchdog Random Access Memory (RAM) is a type of memory used for temporary storing data and
• Analog to Digital Converter intermediate results created and used during the operation of the microcontrollers. The content of this
• Oscillator memory is cleared once the power supply is off.
• Program RAM is volatile memory. It stores the variables of the program.

Electrically Erasable Programmable ROM (EEPROM)


The EEPROM is a special type of memory not contained in all microcontrollers. Its contents may be
changed during program execution (similar to RAM ), but remains permanently saved even after the
loss of power (similar to ROM).
EEPROM is nonvolatile. It stores the variable.
8
Dr. Mohammad Mahbubur Rahman
• Central Processing Unit
• System Bus
• Memory Unit
• Input/Output Port
• Serial Communication
• Timer Unit.
• Interrupt System.
• Watchdog
• Analog to Digital Converter
• Oscillator
• Program

14
Dr. Mohammad Mahbubur Rahman
Serial communication is the most widely
• Central Processing Unit used approach to transfer information
• System Bus (data) between microcontroller and
• Memory Unit peripherals (sensors, communication
• Input/Output Port devices etc)
• Serial Communication The most commonly used serial
• Timer Unit. communication systems are:
• Interrupt System.
• I2C (Inter Integrated Circuit)
• Watchdog
• SPI (Serial Peripheral Interface Bus)
• Analog to Digital Converter
• UART (Universal Asynchronous
• Oscillator
Receiver/Transmitter)
• Program

15
Dr. Mohammad Mahbubur Rahman
• Central Processing Unit Timer Unit. Watchdog
• System Bus
• Memory Unit
• Input/Output Port
• Serial Communication
• Timer Unit.
• Interrupt System.
• Watchdog
• Analog to Digital Converter Timer act as miniature electronic "stopwatches“. These are commonly 8- or 16-bit
• Oscillator SFRs the contents of which is automatically incremented by each coming pulse.
• Program When timer clock comes from peripherals they are called counter.

Pulse Count → Counter


Time Count → Timer
No of rotation per second

16
Dr. Mohammad Mahbubur Rahman
• Central Processing Unit
• System Bus
• Memory Unit
• Input/Output Port
• Serial Communication
• Converts analog signal into digital
• Timer Unit.
• Interrupt System.
signal.
• Watchdog • May have 8-16 bit A/D converter.
• Analog to Digital Converter
• Oscillator
• Program

17
Dr. Mohammad Mahbubur Rahman
• Central Processing Unit I/O Pin
• System Bus
• Memory Unit
• Input/Output Port Timer
Interrupt
• Serial Communication Microprocessor
Controller
• Timer Unit. A/D
• Interrupt System. Converter
• Watchdog
• Analog to Digital Converter Instruction-1
• Oscillator Instruction-1
• Program UART ……………
……………
Why INTERRUPT? ……………
The purpose of the microcontroller is mainly to respond to changes in its surrounding. In …………...
other words, when an event takes place, the microcontroller does something. Instruction-N
If the microcontroller spent most of its time endlessly checking peripherals, it would not be
practical at all.
This is why the microcontroller has learnt a trick during its evolution. Instead of checking each pin or bit constantly, the microcontroller
delegates the‘wait issue’to a‘specialist’which will respond only when something attention worthy happens.
18
Dr. Mohammad Mahbubur Rahman
Basic microcontroller architecture (Continued)

RPM Meter

• Read the timer


• Count pulse
• Calculation of RPM
• Displaying Data

Pin Change Interrupt


Processor Go to a special subroutine when any
pulse comes at a input pin

Timer Overflow Interrupt


Go to a special subroutine when set
time is elapsed

14
Dr. Mohammad MahbuburRahman
Name of Some Microcontroller Manufacturer
ATMEL(AVR microcontroller)
Microchip (PIC microcontroller)
Texas Instruments (TI)
Freescale
Philips
Motorola ARDUINO

20
Dr. Mohammad Mahbubur Rahman
Advantages of Arduino: Reduces hardware complexity

Crystal Oscillator Program Loader Microcontroller LinearVoltage Regulator

21
Dr. Mohammad Mahbubur Rahman
Advantages of Arduino: Programming Easy

• Programming in C/C+
• Lot of functions in the library.
• No need to learn internal
architecture of microcontroller.

22 Microprocessor and Interfacing Sessional,Exp-8, By- MohammedAbdul Kader,Assistant Prof., EEE, IIUC
Dr. Mohammad Mahbubur Rahman
Features of Arduino UNO
Microcontroller ATmega328
OperatingVoltage 5V
InputVoltage (recommended) 7-12V
InputVoltage (limits) 6-20V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
32 KB (ATmega328) of which 0.5 KB
Flash Memory used
by bootloader
SRAM 2 KB (ATmega328)
EEPROM 1 KB (ATmega328)
Clock Speed 16 MHz
Length 68.6 mm
Width 53.4 mm
Weight 25 g
Dr. Mohammad Mahbubur Rahman
Digital I/O Pins
▪ Most of the important pins of microcontroller are digital input-output pins.
▪ These pins are used to connect INPUT Device (i.e. Push Button, keypad, digital sensors etc) and OUTPUT
Device (i.e. LED, Display, Relay, Motor etc.) with microcontroller.

▪ These pins can act as INPUT or OUTPUT.


▪ Digital Output pin means microcontroller can make
this pin HIGH or LOW state.

▪ Digital Input pin means microcontroller can read


HIGH or LOW state from other devices

Dr. Mohammad Mahbubur Rahman


Configuring Digital I/O Pins
Configuring as OUTPUT
▪ An LED is connected with pin 13.
▪ The pin should be an OUTPUT pin.
▪ We can configure a pin as OUTPUT by “pinMode”
function.

pinMode(pin Number, OUTPUT)


pinMode(13, OUTPUT)

Making a Pin HIGH or LOW


▪ Microcontroller can make a digital pin HIGH or LOW by
digitalWrite function.
digitalWrite(pin number, HIGH/LOW)
digitalWrite(13,HIGH)
digitalWrite(13,LOW)

Dr. Mohammad Mahbubur Rahman


Program Structure in ARDUINO
Verify Program
Serial monitor
Load Program

Processor run the instructions


written here only once after
loading program or reset .

Processor run the instructions written here


repeatedly after loading program or reset .
i.e. void loop() function creates an infinite
loop.
Microprocessor and Interfacing Sessional,Exp-8, By-Mahbubur
Dr. Mohammad MohammedAbdul
Rahman Kader,Assistant Prof., EEE, IIUC
Task-1: LED Blinking

void setup()
{
pinMode(13,OUTPUT);
}
void loop()
{
digitalWrite(13,HIGH);
delay(300);
digitalWrite(13,LOW);
delay(300);
}
Note: To insert a time delay in the program use following function-
delay(time_in_ms);

Dr. Mohammad Mahbubur Rahman

You might also like