8051 Microcontroller: Subject: Microprocessor and Microcontroller Subject Coordinator-Dr Sunanda Ambulker
8051 Microcontroller: Subject: Microprocessor and Microcontroller Subject Coordinator-Dr Sunanda Ambulker
8051 Microcontroller: Subject: Microprocessor and Microcontroller Subject Coordinator-Dr Sunanda Ambulker
microcontroller I
It Is a small computer on a single integrated circuit chip.
On the same chip, a microcontroller typically contains a
processor and additional peripherals (memory(RAM and
ROM), serial interface, timer, programmable I/O
peripherals, etc.).
Microprocessor v/s Microcontroller
8051
Single memory to be shared by both Separate memories for code and data.
code and data.
Processor needs to fetch code in a Single clock cycle is sufficient , as
s e p a ra t e c l o c k c yc l e a n d d a t a i n separate buses are used to access code
another clock cycle. So it requires two and data.
clock cycles.
Slower in speed, thus more time- Higher speed, thus less time consuming.
consuming.
Simple in design. Complex in design.
Internal architecture of 8051
8051
Features:
8052:
• 8052 has all the standard features of the 8051 as well as an extra 128
bytes of RAM and an extra timer.
• the 8052 has 256 bytes of RAM and 3 timers.
• It also has 8K bytes of on-chip program ROM instead of 4K bytes
8051 Family
• Other members of 8051 Family
8031
• This chip is often referred to as a ROM-less 8051 since it has OK
bytes of on-chip ROM.
• To use this chip you must add external ROM to it. This external ROM
must contain the program that the 8031 will fetch and execute.
• Contrast that to the 8051 in which the on-chip ROM contains the
program to be fetched and executed but is limited to only 4K bytes of
code. The ROM containing the program attached to the 8031 can be
as large as 64K bytes.
• In the process of adding external ROM to the 8031, two ports will be
lost.
Criteria for choosing microcontroller
• Immediate
• Register
• Direct
• Register Indirect
• Indexed
Addressing modes
• MOV A,#65H
• MOV A,#’A’
• MOV R6,#65H
• MOV DPTR,#2343H
• MOV P1,#65H
Addressing modes
The C in MOVC instruction refers to code byte. For the first instruction,
let us consider A holds 30H. And the PC value is1125H. The contents of
program memory location 1155H (30H + 1125H) are moved to register
A.
Instruction set
The instructions of 8051 Microcontroller can be classified into five
different groups.
M1 M0 Mode Operation
13-bit timer/counter,
0 (13-bit timer
0 0 8-bit of THx & 5-bit of
mode)
TLx
16-bit timer/counter,
1 (16-bit timer
0 1 THx cascaded with
mode)
TLx
8-bit timer/counter
(auto-reload mode),
2 (8-bit auto- TLx reload with the
1 0
reload mode) value held by THx
each time TLx
overflow
Split the 16-bit
timer into two 8-bit
3 (split timer
Timer
Timer
Two timers T0 and T1
TCON Register
• Bit 4 – TR0:
Timer0 Run Control Bit
•
1 = Timer0 start.
•
0 = Timer0 stop.
• It is set and cleared by software.
• Bit 3 - IE1:
External Interrupt1 Edge Flag
•
1 = External interrupt1 occurred.
•
0 = External interrupt1 Processed.
• It is set and cleared by hardware.
• Bit 2 - IT1:
External Interrupt1 Trigger Type Select Bit
•
1 =
Interrupt occurs on falling edge at INT1 pin.
•
0 =
Interrupt occur on a low level at the INT1 pin.
• Bit 1 – IE0:
External Interrupt0 Edge Flag
•
1 = External interrupt0 occurred.
•
0 = External interrupt0 Processed.
• It is set and cleared by hardware.
• Bit 0 – IT0:
External Interrupt0 Trigger Type Select Bit
•
1 =
Interrupt occurs on falling edge at INT0 pin.
•
0 =
Interrupt occur on a low level at INT0 pin.
Mixed Mode Microcontroller MSP430
• By TI
• Low-power compact microcontroller
• Mixed signal microcontroller
• 16 Register
• 17 instructions
• 7 operating modes
• Von neumann Architecture
Mixed Mode Microcontroller MSP430
• PIN DIAGRAM
Mixed Mode Microcontroller MSP430
VCC and VSS are the supply voltage and ground for the whole device (the
analog and digital supplies are separate in the 16-pin package).
• P1.0–P1.7, P2.6, and P2.7 are for digital input and output, grouped into
ports P1 and P2.
• TACLK, TA0, and TA1 are associated with Timer_A; TACLK can be used
as the clock input to the timer, while TA0 and TA1 can be either inputs or
outputs. These can be used on several pins because of the importance of the
timer.
• A0−, A0+, and so on, up to A4±, are inputs to the analog-to-digital
converter. It has four differential channels, each of which has negative and
positive inputs.
VREF is the reference voltage for the converter.
• ACLK and SMCLK are outputs for the microcontroller’s clock signals.
These can be used to supply a clock to external components or for
diagnostic purposes.
Mixed Mode Microcontroller MSP430
• SCLK, SDO, and SCL are used for the universal serial interface, which
communicates with external devices using the serial peripheral interface
(SPI) or inter-integrated circuit (I2C) bus.
• XIN and XOUT are the connections for a crystal, which can be used to
provide an accurate, stable clock frequency.
• RST is an active low reset signal. Active low means that it remains high
near VCC for normal operation and is brought low near VSS to reset the
chip. Alternative notations to show the active low nature are _RST and
/RST.
• NMI is the nonmaskable interrupt input, which allows an external signal
to interrupt the normal operation of the program.
• TCK, TMS, TCLK, TDI, TDO, and TEST form the full JTAG interface,
used to program and debug the device.
• SBWTDIO and SBWTCK provide the Spy-Bi-Wire interface, an
alternative to the usual JTAG connection that saves pins.
Mixed Mode Microcontroller MSP430
MSP430 architecture
Mixed Mode Microcontroller MSP430
Memory Map
Mixed Mode Microcontroller MSP430
Memory Map
• All memory, including RAM, Flash/ROM, information memory, special
function registers (SFRs), and peripheral registers, are mapped into a single,
contiguous address space
• The MSP430 is available with either Flash or ROM memory types.
• The memory type is identified by the letter immediately following “MSP430”
in the part numbers.
• Flash devices: Identified by the letter “F” in the part numbers, having the
advantage that the code space can be erased and reprogrammed.
• ROM devices: Identified by the letter “C” in the part numbers. They have the
advantage of being very inexpensive because they are shipped pre-
programmed, which is the best solution for high-volume designs.
Mixed Mode Microcontroller MSP430
Memory Map
For all devices, each memory location is formed by 1 data byte. The CPU is
capable of addressing data values either as bytes (8 bits) or words (16 bits).
Words are always addressed at an even address containing the least significant
byte, followed by the next odd address, which contains the most significant byte.
For 8-bit operations, the data can be accessed from either odd or even addresses,
but for 16-bit operations, the data values can only be accessed from even
addresses.
Mixed Mode Microcontroller MSP430
Memory Map
For all devices, each memory location is formed by 1 data byte. The CPU is
capable of addressing data values either as bytes (8 bits) or words (16 bits).
Words are always addressed at an even address containing the least significant
byte, followed by the next odd address, which contains the most significant byte.
For 8-bit operations, the data can be accessed from either odd or even addresses,
but for 16-bit operations, the data values can only be accessed from even
addresses.
Mixed Mode Microcontroller MSP430
Central Processing Unit (MSP430 CPU)
Mixed Mode Microcontroller MSP430
C (Carry flag): It is set to '1' whenever there is a carry out of the final bit when
performing an addition operation. It also works as a borrow flag when performing
subtraction.
Z (Zero flag): This flag is used to indicate whether the result of the ALU operation is
zero or not. It is set when the result is zero, while cleared when the result is non-zero.
Mixed Mode Microcontroller MSP430
MSP430 CPU registers
Status register:
N (Negative flag): This bit indicates the sign of the result of the ALU operation. It is
set if the result is negative, while is cleared if the result is positive. The programmer
has to take care that this bit is referred to or used only if a signed operation is
performed. In case of an unsigned operation this bit is to be ignored.
GIE (General Interrupt Enable): This bit is a control bit for the programmer to
enable and disable the interrupts of the microcontroller. If the programmer sets this bit
to '1', the interrupts are enabled, while if the bit is cleared to '0', the interrupts are
disabled.
CPUOFF (Central Processing unit OFF): This bit when set, switches OFF the CPU
and hence saves power when it is required.
Mixed Mode Microcontroller MSP430
MSP430 CPU registers
Status register:
OSCOFF (Oscillator OFF): This bit when set to '1' by the programmer, the oscillator is
switched OFF and hence saves power.
SCG0 (System Clock Generator bit 0) & SCG1 (System Clock Generator bit 1): These
bits are used to select the clock source for the operation of the microcontroller.
V (Overflow flag): This bit is set to '1' when the result is out of the range for signed
operations. In case if the result is out of the range according to the 2's complement
representation, this bit will be set to indicate the user that the result is out of range, and hence
the result value is incorrect. In other words, you can say if the sum of two positive numbers
gives negative result or sum of two negative numbers gives positive result, the overflow bit is
set to '1'. In other cases it is cleared.
FRAM
• Random Access Memory (e.g., Dynamic RAM, Static RAM) has the advantage
that it has fast read/write access, but it is volatile in nature, which means that
we need a constant power supply to maintain the data in memory. On the
other hand, Read Only Memory (ex. EEPROM, FLASH) has the advantage of
being non-volatile, but at the same time, it is very slow as compared to RAM.
FRAM combines the best of the two types of memories, which means that it is
non-volatile and also has fast read/write access.
• The key features of FRAM are:
• • Consumes less power.
• • Can tolerate radiation.
• • Is more secure than other memory types.
• • Has high endurance for read/write cycles.
• • Is over-writable like SRAM.
• • Less expensive than magnetic memories
FRAM
• Random Access Memory (e.g., Dynamic RAM, Static RAM) has the advantage
that it has fast read/write access, but it is volatile in nature, which means that
we need a constant power supply to maintain the data in memory. On the
other hand, Read Only Memory (ex. EEPROM, FLASH) has the advantage of
being non-volatile, but at the same time, it is very slow as compared to RAM.
FRAM combines the best of the two types of memories, which means that it is
non-volatile and also has fast read/write access.
• The key features of FRAM are:
• • Consumes less power.
• • Can tolerate radiation.
• • Is more secure than other memory types.
• • Has high endurance for read/write cycles.
• • Is over-writable like SRAM.
• • Less expensive than magnetic memories
INTERFACING DEVICES WITH 8051