PROGRAMS TO BE EXECUTED - 4 | EXPERIMENT NO. 3 TITLE: Parallel I/O Interfacing with 8085 (8255 Programmable Peripheral Interface) | Microcontroller Lab
K12 Students

Academics

AI-Powered learning for Grades 8–12, aligned with major Indian and international curricula.

Professionals

Professional Courses

Industry-relevant training in Business, Technology, and Design to help professionals and graduates upskill for real-world careers.

Games

Interactive Games

Fun, engaging games to boost memory, math fluency, typing speed, and English skills—perfect for learners of all ages.

Interactive Audio Lesson

Listen to a student-teacher conversation explaining the topic in a relatable way.

Overview of 8255 Initialization and Mode Configuration

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Today, we'll discuss how to initialize the 8255. Can anyone tell me what the first step is before we can take control of the ports?

Student 1
Student 1

We need to write a control word to the Control Word Register.

Teacher
Teacher

Exactly! The control word specifies how the ports will operate. Remember, the control word consists of different bits that denote modes and directions for Port A, Port B, and Port C.

Student 2
Student 2

What’s the significance of D7 in the control word?

Teacher
Teacher

Good question! D7 sets the mode: 1 for I/O mode and 0 for BSR mode. It’s crucial for determining port operations.

Student 3
Student 3

Can you give us an example of a control word?

Teacher
Teacher

Sure! For configuring Port A as output, we might use 8AH as the control word, where D7 is 1, indicating I/O mode, and D4 is 0, meaning Port A is set as output. Let's remember to use the mnemonic 'I for Input, O for Output' to track direction!

Student 4
Student 4

That’s helpful! So, we need to calculate the control word based on our desired configurations.

Teacher
Teacher

Exactly! Let’s summarize: initialization requires writing the control word to the 8255 CWR, which dictates the operational modes of our ports.

Blinking LEDs with 8255

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Now, let’s move to the program that makes LEDs connected to Port A blink. Can anyone tell me why we configure the port first?

Student 1
Student 1

It’s to ensure the port is set correctly for output before we start sending data.

Teacher
Teacher

Correct! The assembly code first initializes the PPI with a control word for output. Can anyone summarize the flow of the blinking program?

Student 2
Student 2

We load the control word into the accumulator, output it to the CWR, and then loop to turn the LEDs on and off with delays in between.

Teacher
Teacher

Exactly! The pattern is to use `MVI A, FFH` to turn all LEDs on, followed by calling a delay. The blinking is achieved through repeated loops. Who remembers how we create the delay?

Student 3
Student 3

We use nested loops to create a software delay.

Teacher
Teacher

That’s right! Using nested loops allows us to create a significant wait time between turning the LEDs on and off. Let’s move to summarize our key steps for this program.

Student 4
Student 4

We first need to set our ports, then output a pattern to make the LEDs blink, using simple looping for timing.

Teacher
Teacher

Great summary! Always remember the significance of control words and loops in microcontroller programming.

Reading Switch Inputs

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Let’s explore how to read inputs from switches connected to Port B now. What do we need to configure for this task?

Student 1
Student 1

We need Port B set as input and Port C as output.

Teacher
Teacher

Correct! We configure the control word to specify Port B as input. But how do we read and process the data?

Student 2
Student 2

We use the `IN` instruction to read the data from Port B into the accumulator.

Teacher
Teacher

Masking is necessary to isolate the inputs we care about, ensuring only the switch states are processed.

Student 3
Student 3

And we output the result to Port C to control the LED states based on the switch inputs.

Teacher
Teacher

Great understanding! So we gather the switch input and display it on LEDs connected to Port C. What’s the main loop's purpose?

Student 4
Student 4

To continuously read the switch state and update the output accordingly.

Teacher
Teacher

Exactly! This reflects the real-time interaction we seek with peripherals using the 8255 PPI. Let's summarize this!

Introduction & Overview

Read a summary of the section's main ideas. Choose from Basic, Medium, or Detailed.

Quick Overview

This section introduces practical assembly programs to interface the 8255 Programmable Peripheral Interface with the 8085 microprocessor.

Standard

In this section, we will explore three practical assembly programs designed to operate the 8255 PPI with the 8085 microprocessor. The programs will configure the 8255 for various functions such as outputting static data, blinking LEDs, and reading switch inputs.

Detailed

Programs to be Executed with the 8085 and 8255

This section outlines practical programs that demonstrate the interaction between the 8085 microprocessor and the 8255 Programmable Peripheral Interface (PPI). These programs are designed to utilize the capabilities of the 8255, which can be configured to perform various I/O operations through different modes.

Program Objectives

  1. Program 1: Configure the 8255 for Mode 0, output a static byte to Port A.
  2. Program 2: Blink LEDs connected to Port A, demonstrating continuous output control.
  3. Program 3: Read input from switches connected to Port B and display the state on Port C lower.

Each program includes details on the control word configuration needed for the 8255, the assembly code required to execute the function, and expected outcomes after program execution. The results help in visualizing the operation of the mentioned I/O devices, such as LEDs and switches, connected to the 8085 microprocessor.

Audio Book

Dive deep into the subject with an immersive audiobook experience.

Overview of Programs

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

Assume 8255 I/O addresses: Port A = 80H, Port B = 81H, Port C = 82H, Control Word Register (CWR) = 83H.

Detailed Explanation

This section provides the I/O addresses for the 8255 Programmable Peripheral Interface (PPI) components. Port A, Port B, Port C, and the Control Word Register have specific hexadecimal addresses assigned for communication. When programming the 8085 microprocessor, these addresses must be used to access the respective ports and register correctly.

Examples & Analogies

Think of these addresses as house numbers. Just like you need to know the correct house number to send a letter to a specific person, the microprocessor needs to know these I/O addresses to send data to the correct port on the PPI.

Program 1: Static Output to Port A

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

Objective: To configure 8255 for Mode 0 (Port A as Output, Port B as Input, Port C Lower as Output, Port C Upper as Input) and then output a fixed data byte (55H) to Port A.

Control Word Calculation (I/O Mode):
- D7 = 1 (I/O Mode)
- D6, D5 (Group A Mode) = 00 (Mode 0)
- D4 (Port A Direction) = 0 (Output)
- D3 (Port C Upper Direction) = 1 (Input)
- D2 (Group B Mode) = 0 (Mode 0)
- D1 (Port B Direction) = 1 (Input)
- D0 (Port C Lower Direction) = 0 (Output)

Resulting Control Word (Binary): 10001010b = 8AH (Hex)

Assembly Code:

; Program to initialize 8255 and output static data to Port A
; Starting Address: 2000H
ORG 2000H
MVI A, 8AH ; Load Accumulator with 8255 Control Word for desired configuration
OUT 83H ; Write Control Word to 8255 CWR (Port A=Out, B=In, C_L=Out, C_U=In)
MVI A, 55H ; Load Accumulator with data to be sent to Port A
OUT 80H ; Output data (55H) to Port A (connected to LEDs)
HLT ; Halt processor execution

Expected Outcomes:
- Port A LEDs should display the binary pattern for 55H (01010101b).
- Registers: A = 55H, PC = 2009H.

Detailed Explanation

This program demonstrates how to initialize the 8255 and send a fixed data value (55H) to Port A. First, it configures the ports using a control word that specifies the operation modes of the ports. In this case, Port A is set to output mode, allowing it to control connected LEDs. The program then loads this control word into the microprocessor and sends it to the 8255. After that, it loads the value 55H, which corresponds to the binary pattern 01010101, into the accumulator and outputs this value to Port A, turning specific LEDs ON and OFF based on that pattern.

Examples & Analogies

Imagine you are a teacher setting a specific task for your students (the LEDs). By configuring the control word, you tell each student (the port) what to do (whether to be an input or output). Sending the value 55H is like instructing certain students to raise their hands (at certain times), indicating their position (ON/OFF).

Program 2: Blinking LEDs Connected to Port A

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

Objective: To configure 8255 Port A as output and continuously blink LEDs connected to it (turn ON, delay, turn OFF, delay).

Control Word Calculation (I/O Mode):
- D7 = 1 (I/O Mode)
- D6, D5 = 00 (Group A - Mode 0)
- D4 (Port A Direction) = 0 (Output)
- D3 (Port C Upper Direction) = 1 (Input - chosen arbitrarily as it doesn't affect this program's core logic)
- D2 = 0 (Group B - Mode 0)
- D1 (Port B Direction) = 1 (Input - chosen arbitrarily)
- D0 (Port C Lower Direction) = 0 (Output - chosen arbitrarily)

Resulting Control Word (Binary): 10001010b = 8AH (Hex)

Assembly Code:

; Program to blink LEDs connected to Port A of 8255
; Starting Address: 2000H
ORG 2000H
; --- 8255 Initialization ---
MVI A, 8AH ; Load 8255 Control Word (Port A=Out, B=In, C_L=Out, C_U=In)
OUT 83H ; Write Control Word to 8255 CWR
; --- Main Blinking Loop ---
LOOP_START:
MVI A, FFH ; Load Accumulator with FFH (All LEDs ON)
OUT 80H ; Output to Port A
CALL DELAY ; Call delay subroutine
MVI A, 00H ; Load Accumulator with 00H (All LEDs OFF)
OUT 80H ; Output to Port A
CALL DELAY ; Call delay subroutine
JMP LOOP_START ; Jump back to LOOP_START to repeat blinking
; --- Delay Subroutine (Simple software delay) ---
DELAY:
MVI C, 0FFH ; Load C register with FFL (outer loop count)
DELAY_OUTER:
MVI B, 0FFH ; Load B register with FFL (inner loop count)
DELAY_INNER:
DCR B ; Decrement B
JNZ DELAY_INNER ; If B not zero, jump back to DELAY_INNER
DCR C ; Decrement C
JNZ DELAY_OUTER ; If C not zero, jump back to DELAY_OUTER
RET ; Return from subroutine

Expected Outcomes:
- LEDs connected to Port A should continuously blink (all ON for a short duration, then all OFF for a short duration).

Detailed Explanation

This program configures Port A to output mode and creates a simple loop that turns all LEDs ON by sending the value FFH, followed by a delay, and then turns them OFF by sending the value 00H with another delay. The 'DELAY' subroutine creates a pause between turning the LEDs ON and OFF, resulting in a blinking effect. This continuous loop gives the perception of blinking, necessary when working with light-emitting diodes (LEDs) in various electronic projects.

Examples & Analogies

Think of flipping a light switch ON and OFF repeatedly, like a person signaling for attention. In this scenario, the microprocessor is similar to a person controlling the lights. The delays act like the pauses before the next signal, allowing onlookers to see the lights blink rather than stay solid.

Program 3: Read Switch Inputs from Port B and Display on Port C Lower

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

Objective: To configure Port B as input and Port C Lower as output (Mode 0). Read the state of 4 switches connected to PB0-PB3, then output this 4-bit data to PC0-PC3 to display on LEDs.

Control Word Calculation (I/O Mode):
- D7 = 1 (I/O Mode)
- D6, D5 = 00 (Group A - Mode 0)
- D4 (Port A Direction) = 1 (Input - arbitrary as not used)
- D3 (Port C Upper Direction) = 1 (Input - arbitrary)
- D2 = 0 (Group B - Mode 0)
- D1 (Port B Direction) = 1 (Input)
- D0 (Port C Lower Direction) = 0 (Output)

Resulting Control Word (Binary): 10011010b = 9AH (Hex)

Assembly Code:

; Program to read switches from Port B and display on Port C lower
; Starting Address: 2000H
ORG 2000H
; --- 8255 Initialization ---
MVI A, 9AH ; Load 8255 Control Word (Port A=In, B=In, C_L=Out, C_U=In)
OUT 83H ; Write Control Word to 8255 CWR
; --- Main Loop to Read and Display ---
READ_LOOP:
IN 81H ; Read data from Port B (connected to switches) into Accumulator
ANI 0FH ; Mask out higher nibble (keep only lower 4 bits for switches PB0-PB3)
OUT 82H ; Output Accumulator content to Port C (PC0-PC3 will show switch states)
JMP READ_LOOP; Jump back to READ_LOOP to continuously read

Expected Outcomes:
- LEDs connected to PC0-PC3 should reflect the exact binary state of the switches connected to PB0-PB3. For example, if PB0 and PB2 are ON (switches closed, assuming active high or pull-up/low logic), and PB1, PB3 are OFF, the LEDs on PC0 and PC2 should be ON.

Detailed Explanation

In this program, Port B is configured as an input to read the state of switches, and Port C Lower is set as an output to show the status of those switches on connected LEDs. The program continuously reads the state of Port B, masks the higher bits of the input to only keep the relevant lower 4 bits that correspond to the switch states, and sends this information to Port C. As a result, the LEDs connected to Port C will display whether the corresponding switches connected to Port B are ON or OFF.

Examples & Analogies

Think of this process as conducting a survey where you ask four friends (switches) whether they want pizza or salad. Each friend answers with a 'yes' (ON) or 'no' (OFF). You then display the answers on a board (LEDs). Every time you ask the question (the read operation), the friends might change their preference, and you want the board to reflect their most recent answers in real time.

Definitions & Key Concepts

Learn essential terms and foundational ideas that form the basis of the topic.

Key Concepts

  • Control Word: The configuration word written to the CWR to establish I/O operation modes.

  • Mode 0: A basic configuration setting used for most straightforward I/O tasks.

  • BSR Mode: Allows for individual bit manipulation on Port C.

  • Interfacing: Connecting the 8255 PPI to the 8085 microprocessor for direct communication.

Examples & Real-Life Applications

See how the concepts apply in real-world scenarios to understand their practical implications.

Examples

  • Example of a control word to set Port A as output and Port B as input: 8AH.

  • Blinking LEDs program using assembly to demonstrate continuous output.

Memory Aids

Use mnemonics, acronyms, or visual cues to help remember key information more easily.

🎵 Rhymes Time

  • To blink the LED at a steady pace, initialize the port, set the control word in place.

📖 Fascinating Stories

  • Once a microprocessor wanted to control LEDs. It needed a wise PPI friend to tell it how to send signals. Together they configured ports and made the LEDs shine, blinking with joy as they danced in time.

🧠 Other Memory Gems

  • I for Input, O for Output – remember the directions for the 8255 setup!

🎯 Super Acronyms

PPI

  • Programming Parallel Interfaces – think of how the 8255 helps programs communicate with the outside world.

Flash Cards

Review key concepts with flashcards.

Glossary of Terms

Review the Definitions for terms.

  • Term: 8255 Programmable Peripheral Interface (PPI)

    Definition:

    A device that allows microprocessors to interface with parallel I/O devices, providing programmable I/O pins for input and output operations.

  • Term: Control Word Register (CWR)

    Definition:

    A register in the 8255 PPI used to configure the operational modes and directions of its ports.

  • Term: Mode 0

    Definition:

    A basic I/O mode where all ports can function as input or output without handshaking.

  • Term: Bit Set/Reset (BSR) Mode

    Definition:

    A mode allowing individual bits of the Port C pins to be set or reset without affecting other pins.

  • Term: I/O Mode

    Definition:

    A mode which configures the ports for input/output operations, with multiple sub-modes available.