Chapter 2
Chapter 2
Chapter 2
(a) (b)
Power on Reset
• In 8051 POR consist of resistor and capacitor
• As capacitor gets charged, the voltage at reset
pin falls exponentially
Brown Out Reset
• When battery gets drained, MCU may not work correctly
– Wrong decision and actions
• To protect the system from such situation
– It is ensured that if power supply voltage goes below a
specified level, the MCU should be reset
• The 8051 family does not have “Brown OUT Reset”
feature
Brown out reset
Timers and Counters
Timer
• MCUs have timers as peripherals
• Timer is a dedicated hardware for ‘timing’ events
– Processing unit does not interfere, once timer is started
(H/W will take care of it)
• Timer count register and mode register associated
(Other registers may also be associated)
Timers and Counters
• Processor clock works as reference clock
• Clock frequency can be divided to get lower frequency clock
Working of Timer
– Number is loaded in timer count register
– Timer is started
– Counter keeps increasing or decreasing until it reaches maximum or
minimum value
– At this point, count register reset to 0
– Interrupt or flag bit set to indicate this
Timers and Counters
Counter
• Counts external events
• Generally does not use processor clock
• Count register associated with counter gets
incremented for each occurrence of event
under consideration
Watchdog Timer
• Does a ‘monitoring’ job and resets the system, if
necessary
• Fulfil the characteristics of ‘self-reliant’ in
embedded system
– Reduces human intervention in case associated
software get stuck in infinite loop
• Similar to any other timer
Watchdog Timer
• Loaded with a ‘count’ which decrements
down to 0
• If reaches to 0, resets the processor.
• If system is doing it job correctly, s/w will
restart it periodically and prevent watchdog
timer to reach 0
Real-time Clock
• Refers to the ‘real’ time
Stack
• Last In First Out (LIFO)
– PUSH and POP operation
• Ascending stack
– Starts from low memory address
– On PUSH operation, item stored in higher memory address
• Descending stack
– Grows downwards
Stack
PUSH and POP operation in descending stack
Stack
PUSH and POP operation in ascending stack
Interrupts
• For executing more important activity by
suspending current activity in execution
• In case of interrupt, processor completes the
instruction it is currently running
• Takes up the new task
• Once interrupting task is over, return and continue
execution previous task
Interrupts
Key points
• Processor must save its current status
– Content of registers (in stack), address of next instruction (value of
program counter)
• ‘Branch’ to the program for which interrupt was generated
(Instructions of interrupt program designated as ‘Interrupt Service
Routine’)
– Interrupt vector stores address of first instruction of ISR
• After execution, ‘return’ and resume execution where it had left
Interrupts
What are the ways by which a processor can be interrupted?
• Done by hardware (activate interrupt pin of the processor
e.g. pin 12 of 8051)
• Using MCUs inbuilt peripherals
– Interrupt by timer
• Software interrupts (write instructions in program)
– Mostly applicable in MPUs
Interrupt structure of 8051
• Five interrupts excluding reset
Interrupt structure of 8051
• Two external hardware pins INT0 and INT1
– Pin 12 and 13
• Two timer interrupts Timer0 and Timer1
• Serial communication interrupt
– Serial transmission as well as reception
Direct Memory Access
• To send data in memory to I/O or vice versa
– Print a large chunk of data
– No involvement of the processor
• To isolate processor from this process
– Connection to memory and I/O is blocked
– Buses of the processor are to be tri-stated (High
Impedance state
Direct Memory Access
Processor buses in float state during DMA
operation
Communication Ports
• MCUs have UART as standard peripheral
– Registers, Pins and interrupts associated with this
peripheral
• In 8051 pins 10 and 11 for serial reception and
transmission
Memory for Embedded System
• Random Access Memory
– Static RAM
– Dynamic RAM
– SD RAM
• Read Only Memory
Introduction
• RAM and ROM inside processor chip.
• Size of memories varies chip to chip.
• If requirements of memory are more than the
available on chip, external memory can be
added.
Semiconductor Memory
• Data is stored in memory and it is usually defined
as byte oriented i.e. One address corresponds to
one byte in the memory .
• When one address is accessed one byte is read or
written into it.
• For getting a word of four bytes, four consecutive
locations with four addresses have to be accessed.
Semiconductor Memory
• Reading and writing takes some amount of time
which is termed as memory access time.
• For reading, it is time when address is placed at
address pins and data is available at the data pins.
• Memory cycle time is the time interval between
two consecutive memory accesses.
RAM
• RAM –Random Access Memory
• In which any location can be accessed randomly
with same latency.
• It is volatile memory -power removed, data lost.
• Fastest and most expensive RAM is SRAM i.e.
Static RAM.
SRAM
• Each cell holds either 0 or 1.
• This content is static, because content is stored
as voltage which does not change with time.
• Memory is realized using MOSFETs and the most
commonly used type of memory cell needs six
transistors and is called 6T cell.
SRAM Memory Cell
SRAM Memory Cell
• It has two cross coupled NMOS transistors (N1
and N2) acting as bistable multivibrator and two
PMOS transistors (P1 and P2) acting as their
loads.
• The access transistors N3 and N4, and the
wordline WL and bitlines BL and Blbar are used to
read and write to and from the cell.
SRAM Memory Cell
• When no reading or writing is required, word line is low,
turning N3 and N4 off.
• To write data into the cell, logic data is placed on the bit line
and complementary on inverse bit line.
• Then access transistors are turned ON by setting word line
to high.
• For reading, the word line is turned ON to activate the
access transistor while the information is sensed at bitlines.
SRAM Chip
• N address lines, 8 data lines and
control signals for reading and
writing.
• CE line is activated, chip become
usable.
• WR is write control signal and
• OE is read control signal signals.
• It enables the data lines for
reading
SRAM Asynchronous Read
timing
SRAM Read cycle
1. Place the address of byte to be read, on the
address bus.
2. Ensure chip is activated by making CE low.
3. Activate OE pin which is RD pin itself. This
ensures that data is read.
4. The required data then appears on the data bus.
SRAM Read cycle
• Read Access time: this is the time measured from the
instant the address is placed on the address bus to the
point in time when the required data is available on the
data pins. TAA shown in diag.
• Read cycle time: minimum time between two read cycles.
These can be equal for SRAM as data is available at data
pins, it can be read by processor and a new read cycle can be
initiated.
Asynchronous write Timing
Memory write cycle
1. Place the address of byte to be written on the
address bus.
2. Ensure that the chip is activated by making CE low.
3. Place the data to be written on the data bus.
4. Activate the WR line. Only then the data is
considered to be valid
5. The data is then written into the addressed location.
Merits and Demerits of SRAM
Merits Demerits
• CMOS is used. It uses less power than • At higher frequencies, it can
DRAM consume significant amount
• They are as fast as CPU because of
using the same technology as the CPU.
of power.
• Any MCU will have a certain amount of • Quite Expensive.
SRAM inside it by the name on chip
RAM.
• For many MCUs this SRAM includes the
internal registers which are arranged as
banks.
Synchronous SRAM(SSRAM)
• Ordinary SRAMs are asynchronous as there is no
clock signal for timing the read and write operations.
• In such synchronous SRAM, processor clocks create
the timing for read and write.
• SSRAMs are used in high speed applications.
• They are used as cache for power PC and Pentium –
based workstations.
Dynamic RAM(DRAM)
• It is designated as dynamic because its content
does not remain unchanged or static as in SRAM
and hence frequent refreshing is necessary.
• A DRAM memory cell consists of a single field
effect transistor(FET) and a capacitor.
• Amount of charge stored in the capacitor that
decides whether the cell stores 1or 0.
Dynamic RAM(DRAM)
• Capacitor does not hold charge indefinitely as
the charge in a capacitor ‘leaks off’ and needs
to be replenished.
• This action of replenishing the charge that
gets lost is done by refreshing the cell at
regular intervals.
DRAM Memory Cell
Memory Control of DRAM
• Word line and read line are connected as shown to
select the required bit within memory to be read or
written to.
• Multitudes of Such cells form word consisting of bits
• Memory addresses are decoded and converted as
rows and columns of matrix that memory elements
are arranged in
Read Cycle of DRAM
• Processor when address memory sends the
complete address on its address pins.
• Between processor and DRAM chip there is a
memory controller whose function is to split
the address into two as columns and rows
Memory Control of DRAM
• A DRAM has only half the no. of address [ins as
the address supplied by processor, because the
address pins of DRAM chip are multiplexed in
time for row and column addresses.
• The memory controller should also generate the
signals necessary for reading or writing to DRAM.
Memory Control of DRAM
Memory Control of DRAM
• Because row and column address information
is placed on same address lines the pin count
of DRAM is reduced.
• Each cell has a unique location or address
defined by intersection of row and a column.
Internal Diagram DRAM Chip
DRAM Read Cycle
• The row address is placed on address lines and
given sufficient time to stabilize and be latched.
• The row address strobe RAS signal is activated.
• The row address decoder selects the proper row.
• The column address is placed on same address
lines and allowed to stabilized and latched.
DRAM Read Cycle
• The CAS also serve as output enable, so once CAS
signal has been stabilized, the sense amps place the
data from selected row and column, on the data bus.
• The data in the selected address is available at output
buffers of the chip and it is transferred to data bus.
• Before read cycle can be considered complete CAS and
RAS must be returned to their previous state.
DRAM Read Cycle
DRAM Read Cycle
• Trac=Access time for RAS
is time from the time RAS signal is activated to the
time data is available on the data bus.
The read cycle time (Trc) is sum of ‘RAS active time’
and ‘RAS precharge time’.
RAS active Time- Time for which RAS signal is
active.
DRAM Read Cycle
• RAS Precharge Time(trp):it is additional time needed before a new read cycle
can be started.
• Packing Density is high as one transistor for one bit, while SRAM six T for one
bit.
Refreshing
• Refreshing : Each row should be refreshed every
64msec
How is refreshing done?
There are many methods for refresh and one
commonly used method is ROR (RAS only Refresh).
By activating each row using RAS.
DRAM Read Cycle
• DRAM controller takes care of scheduling the refreshes and making sure that they do
not interfere with regular reads and writes
• To keep data in DRAM chip away, the DRAM controller periodically sweeps though all
of rows by cycling repeatedly and placing a series of row addresses on address bus.
This method is called ROR.
• To reduce the number of refresh cycles, one method of design is to split the address
such that there are fewer rows and more columns.
Mode Register: There is a command register for this RAM into which
common words are written to specify various operating modes and
also generate various control signals. It makes RAM ‘programmable’.
Synchronous Vs Asynchronous DRAM
Asynchronous synchronous
• Shares a common clock with CPU,
• Does not share any common clock commands can be placed on its control
with CPU, the controller chips have to pins on clock edges.
manipulate the DRAM’s control pins
based on all sorts of timing
considerations. • In SDRAM, the input signals are latched
into control logic block which functions
• For Accessing Memory, toggling of the as input to a state machine.
external control inputs has a direct • State Machine controls memory Access.
effect on internal memory array.
• Read, write and refresh are initiated by
loading control commands into device.
DDR (Double Data Rate) SDRAM
• It can be made to transfer data at rising and falling edges of the clock, instead of
just at rising edge.
• DDR-2 and DDR-3:Just double data rate as with DDR.The additional signals
required for differential pairs add to pin count of DDR2 and DDR3.
ROM(Read Only Memory)
• User burn the contents of this which is not lost when power is switched off.