Module-1-Microcontrollers – Slide set-2
8051 Block Diagram
8051 Internal Block Diagram
Features of 8051
Features of 8051
8051 Memory
The data width is 8 bits
Registers are 8 bits
Addresses are 8 bits
i.e. addresses for only 256 bytes!
PC is 16 bits (up to 64K program memory)
DPTR is 16 bits (for external data - up to 64K)
Program Memory
Program and Data memory are separate
Can be internal and/or external
20K internal flash for the Atmel controller
Read-only
Instructions
Constant data
Data Memory
External Data - xdata
Resides off-chip
Accessed using the DPTR and MOVX instruction
We will not use xdata
We will use the SMALL memory model
all data is on-chip
limited to only ~128 bytes of data!
Internal data memory contains all the processor state
Lower 128 bytes: registers, general data
Upper 128 bytes:
indirectly addressed: 128 bytes, used for the stack (small!)
directly addressed: 128 bytes for “special” functions
Internal Data Memory
Internal data memory contains all the processor state
Lower 128 bytes: registers, general data
Upper 128 bytes:
indirectly addressed: 128 bytes, used for the stack (small!)
directly addressed: 128 bytes for “special” functions
Lower 128 bytes
Register banks, bit addressable data, general data
you can address any register!
Ports
Port 0 - external memory access
low address byte/data
Port 2 - external memory access
high address byte
Port 1 - general purpose I/O
pins 0, 1 for timer/counter 2
Port 3 - Special features
0 - RxD: serial input
1 - TxD: serial output
2 - INT0: external interrupt
3 - INT1: external interrupt
4 - T0: timer/counter 0 external input
5 - T1: timer/counter 1 external input
6 - WR: external data memory write strobe
7 - RD: external data memory read strobe
Ports
Port 0 - true bi-directional
Port 1-3 - have internal pullups that will source current
Output pins:
Just write 0/1 to the bit/byte
Input pins:
Output latch must have a 1 (reset state)
Turns off the pulldown
Turns
pullup must be pulled down by external driver
Just read the bit/byte
Program Status Word
Register set select
Status bits
Timers
Base 8051 has 2 timers
we have 3 in the Atmel 89C55
Timer mode
Increments every machine cycle (12 clock cycles)
Counter mode
Increments when T0/T1 go from 1 - 0 (external signal)
Access timer value directly
Timer can cause an interrupt
Timer 1 can be used to provide programmable baud rate for
serial communications
Timer/Counter operation
Mode control register (TMOD)
Control register (TCON)
Mode Control Register (TMOD)
Modes 0-3
GATE - allows external pin to enable timer (e.g. external pulse)
0: INT pin not used
1: counter enabled by INT pin (port 3.2, 3.3)
C/T - indicates timer or counter mode
Timer/Counter Control Register (TCON)
TR - enable timer/counter
TF - overflow flag: can cause interrupt
IE/IT - external interrupts and type control
not related to the timer/counter
Timer/Counter Mode 0
Mode 1 same as Mode 0, but uses all 16 bits
Timer/Counter Mode 2
8-bit counter, auto-reload on overflow
Timer/Counter Mode 3
Applies to Timer/Counter 0
Gives an extra timer
Interrupts
Allow parallel tasking
Interrupt routine runs in “background”
Allow fast, low-overhead interaction with environment
Don’t have to poll
Immediate reaction
An automatic function call
Easy to program
8051 Interrupts
Serial port - wake up when data arrives/data has left
Timer 0 overflow
Timer 1 overflow
External interrupt 0
External interrupt 1
Microprocessor vs Microcontroller
RISC vs. CISC … functional comparisons . . .
RISC vs. CISC refined comparisons
PIC Microcontroller
PIC is an abbreviation used for Peripheral Interface
Controller. PIC microcontroller is the smallest
microcontroller in the world and are programmed to
execute large number of operations. These were
initially designed to support PDP (programmed data
processor) computers, for controlling the peripheral
devices. It is based on RISC architecture.
A microcontroller is nothing but a combination of processor,
memory and peripherals in a single chip. In a similar way PIC
microcontroller consists of data RAM with some hundred bytes
of ROM for storing the desired program, some I/O ports, one
timer on a single chip having 8 pins.
PIC Microcontroller block diagram
PIC Microcontroller
CPU: CPU is the central processing unit that has ALU, CU, MU within it. The ALU performs
arithmetic and logic operations according to the instructions received. The memory unit stores the
instructions that are to be processed and also the data and instruction after being processed.
While the control unit controls the I/O devices connected to the system.
As it is based on RISC architecture i.e., reduced instruction set computer, then it is to be noteworthy
here that:
The number of instructions is small and approximately around a total of 35 instructions.
Due to less number of instructions, the operation performed by the CPU will be quite fast.
Processing of the instruction takes less time as the length of the instructions is small
RISC architecture also supports less complex compilation and easy debugging.
PIC Microcontroller
Memory: Basically there exist two types of memory in PIC
microcontroller-
1. Program or code memory: As the name itself is suggesting that program
memory holds the set of instructions that are desired to be performed by the
microcontroller. It is basically referred as ROM. The memory space provided by
this is 8K Χ 14 bits that can store 13-bit instruction or program. The PC accesses
the program memory, and increments itself after fetching an instruction.
EEPROM: ROM allows the program to be stored only once. But EEPROM i.e.,
electrically erasable programmable read only memory permits the multiple times
writing of the code on the ROM.
Flash memory: Flash memory is another PROM for this microcontroller. The
program in the flash memory can be erased as many times as required.
PIC Microcontroller
2.Data memory: Data memory stores the data in it. Basically these are Random
Access Memory i.e., RAM. It stores the data on a temporary basis in the
registers. PIC microcontroller holds 368 bytes of RAM which is divided into
banks. The register were the data is stored are classified as:
General Purpose register: These are the registers that perform the general
functions. Like addition, subtraction, multiplication etc. and further storing the
results in other register. Hence no special function is assigned to these
registers, the PIC holds the ability to directly access the data present in these
registers.
Special Purpose register: It is abbreviated as SFR. These registers are assigned
some special functions by the processor and hence are not used for any general
purpose. The operation to be performed by these registers are already set when
the system is manufactured. Hence the functions of these registers are not
variable.
PIC Microcontroller
Some important special function registers are:
STATUS register
TRIS register
PORT register
Like, the function of the STATUS register is to show the status of the program
being performed.
I/O ports:
The number I/O ports is different for different PIC series.
The PIC16 series has 5 I/O port.
These are port A, port B, port C, port D and port E.
Bus:
Bus in this microcontroller is used to communicate between different units within
it.
PIC has 2 types of buses, data bus and address bus.
The data bus transfers the data between memory and I/O unit. Whereas the address
bus holds the address of the location to/ from where the data is loaded or fetched.
PIC Microcontroller
CCP module
The name of CCP module represents capture / compare / PWM(pulse width
modulation), which operates in three modes, such as capture mode, comparison
mode and PWM mode.
Capture mode: the capture mode captures the arrival time of the signal, or when
the CCP pin changes to high level, it captures the value of Timer1.
Comparison mode: the comparison mode is used as an analog comparator. When
the Timer1 value reaches a reference value, it will generate an output.
PWM mode: PWM mode provides pulse width modulation output with 10 bit
resolution and programmable duty cycle.
PIC Microcontroller
Stack:
Since, the priority of critical interrupts are higher than the other tasks, whenever, an interrupt is
generated then the processor of the PIC microcontroller must switch to handle the interrupt by
stopping the operation which is being executed currently.
So, the stack stores the address of the program currently being in execution, until the PIC
microcontroller handles the generated interrupt.
Once the interrupt handling is done, then the processor switches back to the main program whose
address is stored in the stack.
Timers:
PIC microcontroller consists of 3 timers.
Out of the 3, 2 timers i.e., timer 0 and timer 2 are of 8-bit each while timer 1 is of 16 bit.
Advantages of PIC Microcontroller:
1. PIC microcontrollers are consistent and meantime failure percentage of PIC is very less.
2. The performance of the PIC microcontroller is very fast because of using RISC architecture.
3. When comparing to other microcontrollers, power consumption is very less and programming is
also very easy.
4. Interfacing of an analog device is easy without any extra circuitry
Disadvantages of PIC Microcontroller:
1. The length of the program is high due to using RISC architecture (35 instructions)
2. One single accumulator is present and program memory is not accessible
ARM Architecture
ARM is an acronym for Advanced RISC Machines and is a family of RISC instruction set
architectures (ISAs) for computer processors.
It is the most pervasive processor architecture in the world, with more than 270 billion Arm-
based chips have been shipped over the past three decades in products ranging from sensors,
wearables and smart phones to supercomputers.
The architecture has evolved over time, and version seven of the architecture, ARMv7, defines
three architecture "profiles":
A-profile, the "Application" profile, implemented by 32-bit cores in the Cortex-A series and
by some non-ARM cores
R-profile, the "Real-time" profile, implemented by cores in the Cortex-R series
M-profile, the "Microcontroller" profile, implemented by most cores in the Cortex-M series
Benefits of the Arm CPU architecture include:
Integrated security
High performance and energy efficiency
Large ecosystem for global support
Pervasive across markets and locations
Due to their low costs, low power consumption, and low heat generation, ARM processors are
useful for light, portable, battery-powered devices, including smartphones, laptops, and tablet
computers, as well as embedded systems
ARM Microcontroller
ARM Microcontroller
ARM Microcontroller
Jazelle DBX (direct byte code execution) is an extension that allows some ARM processors to
execute Java byte code in hardware as a third execution state alongside the existing ARM and
Thumb modes
ARM Microcontroller