Unit-2: Sensors, Microcontrollers Interfacing
Unit-2: Sensors, Microcontrollers Interfacing
GTU # 3160716
Unit-2
Sensors, Microcontrollers
and their
Interfacing
Prof. Tushar J. Mehta
Computer Engineering Department
Darshan Institute of Engineering & Technology, Rajkot
[email protected]
+91-8866756776
Microcontrollers
Section - 1
Overview of Microcontrollers
Microcontroller is a digital device consisting of CPU, peripheral I/Os, memories, interrupts,
etc. in a single chip or IC.
Microcontroller is a compact integrated circuit designed for a specific operation in an
embedded system.
The examples of various microcontrollers are given as:
5 4 1
digitalRead( ) : Reads digital data from specified pin and stores it into given variable.
Syntax : digitalRead(pin)
Parameters :
Pin : The Arduino digital pin number.
Latitude
Longitude
GPS device with antenna Returns latitude and longitude Tracked Location
for communication as output
CPU
Bus
Oscillator I/O Ports Serial Port
Control
P0 P1 P2 P3
#3160716 (IoT and Applications) Unit 2 – Sensors, Mirocontrollers and their
Prof. Tushar J Mehta 68
Features of 8051 Microcontroller
1. 8- bit microcontroller.
2. Many general purpose and few special function registers (SFRs).
Two major 8 bit registers. A and B. Both are used in arithmetic operations mainly.
A is accumulator and it addressable.
There are 21 SFRs among them few are bit addressable. SFRs perform various dedicated operations.
Also, some control registers for timer, counter and interrupt fall in category of SFRs.
3. Four register banks having 8 registers in each bank.
4. Data pointer register which is 16 bit made from combinations of two 8 bit registers – DPH and
DPL.
5. 16 bit Program Counter.
6. 8 bit Program Status Word(PSW) and used as Flag register.
7. Internal ROM and EPROM.
8. Internal user accessible RAM of 128 Bytes
General Purpose
RAM Area 7Fh
80 Bytes
30h
Internal RAM
30h
(00 – 7Fh)
00h
#3160716 (IoT and Applications) Unit 2 – Sensors, Mirocontrollers and their
Prof. Tushar J. Mehta 74
Special Function Registers
There are 21 SFRs in 8051microcontroller.
They are important set of registers used for dedicated operations in 8051 microcontroller.
Some of the SFRs are bit addressable while others are not.
The following list explains the register and their function. The bracket is representing its
address in RAM.
1. Accumulator – A (E0h)
It is 8 bit register used in each Arithmetic and Logical operation.
It is bit addressable.
All the results of arithmetic or logical operations are stored in Accumulator
One operand in all operations such as addition, subtraction, division and multiplication will be accumulator.
2. Register B (F0h)
It is 8 bit register used in multiplication and division mainly.
It is bit addressable.
MSB LSB
PSW.7 PSW.6 PSW.5 PSW.4 PSW.3 PSW.2 PSW.1 PSW.0
CY AC F0 RS1 RS0 OV - P
D7 D6 D5 D4 D3 D2 D1 D0
CY AC F0 RS1 RS0 OV - P
D7 D6 D5 D4 D3 D2 D1 D0
CY AC F0 RS1 RS0 OV - P
D7 D6 D5 D4 D3 D2 D1 D0
CY – Carry (PSW.7)
Carry flag is set to one when the arithmetic operation has carry generated from D7 bit. It is also used in shift
operations.
CY AC F0 RS1 RS0 OV - P
D7 D6 D5 D4 D3 D2 D1 D0
31 30 29 28 27 8 7 6 5 4 0
N Z C V Unused I F T Mode
Thank
You