Program 3: Read Switch Inputs and Display on Port C Lower - 5.3 | 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.

Introduction to 8255 PPI Configuration

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Today, we're going to discuss how to configure the 8255 PPI to read switch inputs and display outputs. Can anyone tell me the main function of the 8255?

Student 1
Student 1

The 8255 is used to interface microprocessors with peripheral devices for input and output operations.

Teacher
Teacher

Exactly! It allows for communication with devices like switches and LEDs. We'll start by setting up Port B as an input for our switches. Who remembers how to define a control word?

Student 2
Student 2

The control word defines the direction of the ports.

Teacher
Teacher

Correct! Let's calculate the control word for our specific setup. We want Port B as input, which means we need to set that bit correctly.

Student 3
Student 3

So, we write it as: D7=1 for mode set, D6 & D5 for mode, right?

Teacher
Teacher

Very good! After calculating, we find our control word to be `9AH` which sets Port B as input.

Teacher
Teacher

Remember: **M**ode **I**nput **C**ontrol = MIC! Let's keep that in mind.

Understanding the Assembly Program

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Now that we've set up our control word, let’s delve into the assembly code. Can anyone explain the significance of `MVI A, 9AH`?

Student 4
Student 4

It's loading the control word into the accumulator, ready to output it to the 8255.

Teacher
Teacher

Great! Then we output to the Control Word Register. But what do you think the `IN 81H` command does?

Student 1
Student 1

It's reading from Port B, which is connected to our switches.

Teacher
Teacher

Exactly! The next step masks the higher bits with `ANI 0FH`, keeping only our lower 4 bits. Does anyone know why this is important?

Student 2
Student 2

We only need the switch states from PB0 to PB3 to control the display on the LEDs connected to PC0 to PC3.

Teacher
Teacher

Precisely! Now, let’s summarize. Our program reads switch inputs continuously and updates the LEDs accordingly based on the input states.

Practical Observations and Verifying Outputs

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Once we execute the program, what will we observe on the LEDs?

Student 3
Student 3

The LEDs on PC0 to PC3 should reflect the states of the switches connected to PB0 to PB3.

Teacher
Teacher

Correct! If PB0 is ON, PC0 should light up. Let’s write this down: **S**witch **S**tates **R**eflect **O**utput = SSRO. Can someone explain how we'll check our results?

Student 4
Student 4

We can use the `EXAM` command on the trainer to verify the accumulator content after our IN command.

Teacher
Teacher

Exactly! Checking the accumulator will confirm that we are reading the correct switch states. This is a vital part of our troubleshooting process.

Conclusion and Key Learning Points

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

What’s our main takeaway from today’s lesson?

Student 1
Student 1

Understanding how to configure 8255 and write assembly code for I/O operations.

Student 2
Student 2

And how to read inputs and control outputs effectively.

Teacher
Teacher

Exactly! I want you all to remember the acronym FIOR: **F**unctionality of **I**nput and **O**utput via **R**egisters. This sums up our objectives.

Student 3
Student 3

I’ll remember to approach problems by configuring the ports first!

Teacher
Teacher

Good! Practice these concepts at home, and we'll continue building on this knowledge next class.

Introduction & Overview

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

Quick Overview

This program demonstrates how to read switch inputs using Port B and display the status on the lower bits of Port C using the 8255 interface with the 8085 microprocessor.

Standard

The program focuses on configuring Port B as an input to read the status of four switches and Port C Lower as an output to display this information on connected LEDs. Control words are constructed to set up the desired operational modes.

Detailed

Detailed Summary

In this section, we explore the implementation of a program that reads switch inputs via Port B and displays the corresponding binary state on Port C Lower using the 8255 PPI interfaced with the 8085 microprocessor. The aim is to familiarize students with the operation of the 8255 PPI in Mode 0.

Program Overview

The control word for the 8255 is calculated to configure the ports. Port A is set as input (not used), Port B is configured as input to read switches, and the lower four bits of Port C are designated for output to LEDs. The following control word is derived:

  • Control Word: 10011010b (Binary) = 9AH (Hexadecimal)

This configuration allows the program to continuously read from the switches connected to Port B and output their state to the LEDs on Port C Lower. In doing so, it reinforces the principles of input and output operations in microcontroller systems and practical programming techniques. The assembly code provided demonstrates the initialization, data reading, and output stages efficiently.

Audio Book

Dive deep into the subject with an immersive audiobook experience.

Objective of Program 3

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.

Detailed Explanation

The objective of Program 3 is to set up the 8255 interface so that it can read input signals from four switches connected to Port B (PB0 to PB3). This is achieved by configuring Port B as an input port and Port C Lower (PC0 to PC3) as an output port. The state of the switches represents binary data, which will then be displayed on the corresponding LEDs connected to Port C Lower.

Examples & Analogies

Think of this setup like a traffic light system with push-button switches. Each switch represents a different path the traffic can take. Just as the switches control which way the traffic can go based on their states (on or off), this program reads which switches are pressed and lights up the corresponding LEDs to display that information.

Control Word Calculation

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

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)

Detailed Explanation

Before the program can read from the switches and display the results on the LEDs, it needs to send a control word to the 8255. The control word specifies how each port (A, B, C) should be configured. In this case, Port B is set to input to receive the status of the switches, while Port C Lower is configured for output to light up the LEDs. The binary sequence 10011010 reflects this configuration: D7 signals that it's in I/O mode, while the bits that follow dictate the functions of the ports. The hexadecimal equivalent of this binary control word is 9A.

Examples & Analogies

Consider this control word as a set of instructions for a construction team. Just as a construction manager assigns specific tasks to team members (like who builds walls and who installs windows), the control word assigns different roles to the ports in the 8255—defining which will input signals and which will output results.

Assembly Code Overview

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

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
OUT 83H ; Write Control Word to 8255 CWR
; --- Main Loop to Read and Display ---
READ_LOOP:
IN 81H ; Read data from Port B
ANI 0FH ; Mask out higher nibble
OUT 82H ; Output Accumulator content to Port C
JMP READ_LOOP; Jump back to READ_LOOP

Detailed Explanation

The assembly code for Program 3 starts by initializing the 8255 with the previously calculated control word (9A). It then enters an infinite loop labeled READ_LOOP. Within this loop, the program reads the input states from Port B. It uses the ANI instruction to isolate just the lower 4 bits from the data received (to ignore any unrelated bits). Finally, it outputs this 4-bit data to Port C, which activates the appropriate LEDs to reflect the switches' states. The loop continues indefinitely until the system is reset, ensuring constant updates.

Examples & Analogies

Imagine a light control system in a show: the code functions like an operator who continuously checks the status of light switches and instantly turns on the corresponding stage lights. The READ_LOOP is like their routine check: they pause, see which switches are up (lights on) or down (lights off), and then act accordingly to ensure the show's visuals match the audience's experience.

Expected Results

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

Expected Outcomes:
- LEDs connected to PC0-PC3 should reflect the exact binary state of the switches connected to PB0-PB3.

Detailed Explanation

The expected outcome of this program is that the LEDs connected to the pins of Port C Lower (PC0 to PC3) will illuminate, displaying the states of the switches. For example, if a switch connected to PB0 is pressed (ON) while others are not, the LED at PC0 will light up. This visual feedback confirms to the user the input states of the switches in real-time.

Examples & Analogies

Think about a classroom where each student's response to a question is signaled with a light. If a student raises their hand (switch ON), the connected light (LED) turns on, letting the teacher immediately see who wants to answer. This program operates similarly, providing real-time visual feedback based on the switches—just like the teacher relies on observing hands raised to manage class discussion.

Definitions & Key Concepts

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

Key Concepts

  • Control Word: An 8-bit configuration word that directs the behavior of the 8255.

  • Input Ports: Ports configured to receive data from external devices.

  • Output Ports: Ports configured to send data to external devices.

  • Mode 0 Operation: Basic I/O operation where ports act as simple input or output without handshaking.

Examples & Real-Life Applications

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

Examples

  • The control word 9AH is used to set Port B as input and Port C Lower as output for LED display.

  • In this configuration, if switch PB0 is pressed, the LED connected to PC0 will light up.

Memory Aids

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

🎵 Rhymes Time

  • To read from PB, it's easy to see, Just IN 81H, and you’ll agree!

📖 Fascinating Stories

  • Once there was a microprocessor named '8085' who could read switches connected to his friend PPI. They worked together, and every time a switch was pressed, lights would shine bright on the port 'C' below.

🧠 Other Memory Gems

  • Remember: Read Switches Output Input = RSOI, to decode our inputs to outputs.

🎯 Super Acronyms

Use 'SIR' for Switch Inputs Reporting to keep track of reading inputs through Port B.

Flash Cards

Review key concepts with flashcards.

Glossary of Terms

Review the Definitions for terms.

  • Term: 8255 PPI

    Definition:

    The 8255 Programmable Peripheral Interface, a device that facilitates communication between the microprocessor and peripheral devices.

  • Term: Control Word

    Definition:

    An 8-bit word used to configure the functional behavior of the 8255 PPI.

  • Term: Port B

    Definition:

    One of the I/O ports of the 8255, configured for input or output operations.

  • Term: Port C Lower

    Definition:

    The lower 4 bits of Port C used for output; can display an output signal from connected peripherals.

  • Term: Accumulator

    Definition:

    A register in the microprocessor that stores intermediate data and is primarily used in arithmetic and logical operations.