Unit 5-Microcontroller ALP
Unit 5-Microcontroller ALP
Unit 5-Microcontroller ALP
Unit 3:
Conditional loops:
JNZ REPEAT
The stack is a reserved area of the memory in RAM where we can store
temporary information. Interestingly, the stack is a shared resource as it
can be shared by the microprocessor and the programmer. The
programmer can use the stack to store data. And the microprocessor uses
the stack to execute subroutines. The 8085 has a 16-bit register known as
the 8Stack Pointer.9
This register9s function is to hold the memory address of the stack. This
control is given to the programmer. The programmer can decide the
starting address of the stack by loading the address into the stack pointer
register at the beginning of a program.
The stack works on the principle of First In Last Out. The memory
location of the most recent data entry on the stack is known as the Stack
Top.
We use two main instructions to control the movement of data into a
stack and from a stack. These two instructions are PUSH and POP.
PUSH H – The PUSH command will push the contents of the H register
first to the stack. Then the contents of the L register will be sent to the
stack. So the new stack top will hold 34H.
POP D – The POP command will remove the contents of the stack and
store them to the DE register pair. The top of the stack clears first and
enters the E register. The new top of the stack is 12H now. This one
clears last and enters the D register. The contents of the DE register pair
is now 1234H.
Advantages of Subroutine –
1. Decomposing a complex programming task into simpler steps.
2. Reducing duplicate code within a program.
3. Enabling reuse of code across multiple programs.
4. Improving tractability or makes debugging of a program easy.
Ports of 8255A
Operating Modes
three lines from port C as handshake signals. Inputs and outputs are
latched.
• Mode 2 − In this mode, Port A can be configured as the
bidirectional port and Port B either in Mode 0 or Mode 1. Port A
uses five signals from Port C as handshake signals for data transfer.
The remaining three signals from Port C can be used either as
simple I/O or as handshake for port B.
Features of 8255A
8255 Architecture
CS
It stands for Chip Select. A LOW on this input selects the chip and
enables the communication between the 8255A and the CPU. It is
connected to the decoded address, and A0 & A1 are connected to the
microprocessor address lines.
WR
It stands for write. This control signal enables the write operation. When
this signal goes low, the microprocessor writes into a selected I/O port or
control register.
RESET
This is an active high signal. It clears the control register and sets all ports
in the input mode.
RD
It stands for Read. This control signal enables the Read operation. When
the signal is low, the microprocessor reads the data from the selected I/O
port of the 8255.
A0 and A1
These input signals work with RD, WR, and one of the control signal.
Following is the table showing their various signals with their result.
It has 3 counters each with two inputs (Clock and Gate) and one output.
Gate is used to enable or disable counting. When any value of count is
loaded and value of gate is set(1), after every step value of count is
decremented by 1 until it becomes zero.
Depending upon the value of CS, A1 and A0 we can determine
addresses of selected counter.
Applications –
1. To generate accurate time delay
2. As an event counter
3. Square wave generator
4. Rate generator
5. Digital one shot
Introduction of 8237
• The DMA controller temporarily borrows the address bus, data bus
and control bus from the microprocessor and transfers the data
directly from the external devices to a series of memory locations
(and vice versa).
• The DMA controller provides memory with its address, and the
controller signal selects the I/O device during the transfer.
• Data transfer speed is determined by speed of the memory device
or a DMA controller.
• In many cases, the DMA controller slows the speed of the system
when transfers occur.
• The serial PCI (Peripheral Component Interface) Express bus
transfers data at rates exceeding DMA transfers.
• This in modern systems has made DMA is less important.
• The 8237 supplies memory & I/O with control signals and memory
address information during the DMA transfer.
• It is actually a special-purpose microprocessor whose job is high-
speed data transfer between memory and I/O
CAR
CWCR
• The current word count register programs a channel for the number
of bytes to transferred during a DMA action.
CR
BA and BWC
• The base address (BA) and base word count (BWC) registers are
used when auto-initialization is selected for a channel.
• In auto-initialization mode, these registers are used to reload the
CAR and CWCR after the DMA action is completed.
MR
• Each channel has its own mode register as selected by bit positions
1 and 0.
1. Remaining bits of the mode register select operation, auto-
initialization, increment/decrement, and mode for the channel
BR
MRSR
MSR
SR
• The status register shows status of each DMA channel. The TC bits
indicate if the channel has reached its terminal count (transferred
all its bytes).
• When the terminal count is reached, the DMA transfer is
terminated for most modes
of operation.
• The request bits indicate whether the DREQ input for a given
channel is active.
VCC
VSS
GROUND: Ground.
CLK Input
CS Input
RESET Input
RESET: Reset is an active high input which clears the Command, Status,
Request and Temporary registers. It also clears the first/ last flip/flop
and sets the Mask register. Following a Reset the device is in the Idle
cycle.
READY Input
READY: Ready is an input used to extend the memory read and write
pulses from the 8237A to accommodate slow memories or I/O
peripheral devices. Ready must not make transitions during its specified
setup/hold time.
HLDA Input
DB0 ±DB7
DATA BUS: The Data Bus lines are bidirectional three-state signals
connected to the system data bus. The outputs are enabled in the
Program condition during the I/O Read to output the contents of an
Address register, a Status register, the Temporary register or a Word
Count register to the CPU. The outputs are disabled and the inputs are
read during an I/O Write cycle when the CPU is programming the
8237A control registers. During DMA cycles the most significant 8 bits
of the address are output onto the data bus to be strobed into an external
latch by ADSTB. In memory-to-memory operations, data from the
memory comes into the 8237A on the data bus during the read-from-
memory transfer. In the write-to-memory transfer, the data bus outputs
place the data into the new memory location.
IOR Input/Output
I/O READ: I/O Read is a bidirectional active low three-state line. In the
Idle cycle, it is an input control signal used by the CPU to read the
control registers. In the Active cycle, it is an output control signal used
by the 8237A to access data from a peripheral during a DMA Write
transfer.
IOW Input/Output
EOP Input/Output
A0 ±A3 Input/Output
A4 ±A7 Output
HRQ Output
HOLD REQUEST: This is the Hold Request to the CPU and is used to
request control of the system bus. If the corresponding mask bit is clear,
the presence of any valid DREQ causes 8237A to issue the HRQ.
AEN Output
ADSTB Output
MEMR Output
MEMW Output
PIN5 Input