Program 2: Blinking LEDs on Port A - 5.2 | 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.

Understanding the 8255 Control Word

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Today, we're going to learn how to initialize the 8255 PPI. Who can tell me what a control word is?

Student 1
Student 1

Is it like a command that tells the 8255 what to do?

Teacher
Teacher

Exactly! The control word decides the input/output configuration of the ports. For instance, if we want Port A to be an output, what would the specific bit value be?

Student 2
Student 2

It would be '0' for output in the control word format, right?

Teacher
Teacher

Correct! In fact, in our control word, D4 represents Port A direction, and setting it to '0' makes it an output. Remember the control word format: D7 is always '1' for I/O mode.

Student 3
Student 3

What about the other bits?

Teacher
Teacher

Good question! The next two bits control the mode for Group A. Does anyone remember how those bits are arranged?

Student 4
Student 4

M1 and M0, where '00' is for Mode 0!

Teacher
Teacher

Excellent! Summarizing, the control word for our setup looks like this: 10001010 in binary or 8AH in hex.

Implementing the Blinking LEDs Program

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Let's move on to the assembly code now. What will be our first line of code to set the control word?

Student 1
Student 1

MVI A, 8AH to load the control word!

Teacher
Teacher

Correct! After loading, what do we need to do?

Student 2
Student 2

We need to output the control word to the 8255 using OUT 83H.

Teacher
Teacher

Excellent! Now the main blinking loop. What will we do inside that loop?

Student 3
Student 3

We will load FFH into the accumulator to switch on the LEDs and send it to Port A.

Teacher
Teacher

Right! After that, we immediately call the delay subroutine. Why do we need a delay?

Student 4
Student 4

To keep the LEDs on for a while before switching them off!

Teacher
Teacher

Exactly, and then we load 00H to turn the LEDs off before calling the delay again. Finally, we repeat the loop to create continuous blinking.

Delays in Assembly Programming

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Now, let’s discuss the delay subroutine. Why do you think delays are important in our blinking program?

Student 1
Student 1

To make the blinking visible and not too fast to see!

Teacher
Teacher

Correct. A quick blink would not be perceived by the human eye. Let's look at how we set up our delay.

Student 3
Student 3

We use nested loops, right?

Teacher
Teacher

That's one method! What about the registers we use for our loops?

Student 2
Student 2

We can use registers C and B to manage the outer and inner delay loops!

Teacher
Teacher

Exactly! Each loop decrements until it reaches zero before returning from the subroutine.

Student 4
Student 4

So we effectively create a delay by looping multiple times before continuing?

Teacher
Teacher

Precisely! And this is fundamental in ensuring that the LED’s state changes occur at a perceivable rate.

Verification and Observations

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

After running the program, what should we observe with the LEDs connected to Port A?

Student 3
Student 3

They should blink on and off continuously!

Teacher
Teacher

Exactly, but how do we confirm that our program works as intended?

Student 2
Student 2

We can observe the LEDs and check that they blink at a regular interval.

Teacher
Teacher

Good! What if they blink too fast for us to see properly?

Student 4
Student 4

We might need to adjust the delay subroutine to make it longer!

Teacher
Teacher

That’s right! Fine-tuning the delay will improve our visibility of the LED states.

Student 1
Student 1

And if there are any errors, we can recheck the code step by step.

Applications and Practical Use Cases

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Finally, let’s think about where this knowledge might be applied. Can anyone suggest practical uses for blinking LED patterns?

Student 1
Student 1

In signaling or indicating the status of a device!

Teacher
Teacher

Excellent example! How else could we utilize blinking patterns?

Student 2
Student 2

In visual alert systems to draw attention!

Teacher
Teacher

Correct! Blinking LEDs can be effective in many applications beyond simple demonstrations. Can you think of an application in communication?

Student 4
Student 4

Like using LED sequences as a Morse code representation!

Teacher
Teacher

Exactly! This exercise forms a foundational understanding of port interfacing and how we can apply these principles in real-world electronics and systems.

Introduction & Overview

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

Quick Overview

This section focuses on programming the 8255 PPI to blink LEDs connected to Port A using the 8085 microprocessor.

Standard

In this section, students learn to configure the 8255 Programmable Peripheral Interface to control LEDs. They will understand the assembly code necessary to make the LEDs blink, along with the control word format and the use of a delay subroutine for timing.

Detailed

In this detailed explanation, we explore the process of blinking LEDs connected to Port A of the 8255 Programmable Peripheral Interface (PPI) using assembly programming on the 8085 microprocessor. The aim is to configure the I/O ports correctly and implement programming instructions to create an LED blinking effect. Students first initialize the 8255 with the appropriate control word to set Port A as an output port. The assembly code includes a main loop where the accumulator is used to send data to Port A. A simple delay subroutine is implemented to control the on/off timing of the LEDs, effectively demonstrating basic interfacing techniques and assembly language programming.

Audio Book

Dive deep into the subject with an immersive audiobook experience.

Program Objective

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).

Detailed Explanation

The program's aim is to make the LEDs connected to Port A of the 8255 blink on and off. First, Port A is set up to function as an output port, which allows the microcontroller to send signals to the LEDs. Once this is established, the program continuously turns the LEDs on for a set period followed by turning them off for another set period, thereby creating a blinking effect.

Examples & Analogies

Think of it like a traffic light that turns green (ON) to allow cars to go and then turns red (OFF) to stop them. The blinking of the LEDs represents the changing colors of the traffic light, creating an observable pattern of light.

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) = 0 (Output)
● D3 (Port C Upper Direction) = 1 (Input - chosen arbitrarily)
● 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)

Detailed Explanation

The control word is an 8-bit binary number that configures the 8255 for specific operations. Each bit in the control word has a defined purpose, such as determining whether a port is an input or an output. In this case, the configuration sets Port A as an output port to control the LEDs. The binary value '10001010' translates to hexadecimal '8AH', which is what we will write to the control register of the 8255.

Examples & Analogies

Imagine the control word as a light switch panel that controls different sets of lights in a theater. Each switch (bit) dictates whether a particular set of lights (port) should be turned on (output) or off (input). In this program, you are flipping the right switches to ensure the LEDs can be turned on and off.

Assembly Code Explanation

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

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

Detailed Explanation

This assembly code initializes the 8255 by loading the control word into the accumulator and outputting it to the control register. Following this initialization, the main loop begins, which turns on all LEDs by setting the accumulator to 'FFH' and sending the value to Port A. After a pause, it turns off all the LEDs by setting the accumulator to '00H' and outputting that value. The process repeats indefinitely, creating a blinking effect. Additionally, a simple delay subroutine is implemented using nested loops to control the duration of the LED states.

Examples & Analogies

Imagine programming a light show where you set the lights to go on and off rhythmically. Each line of code is like a command you give to the lighting technician, instructing them exactly when to turn the lights on (turn the LEDs on), pause, and then turn them off again. The delay subroutine acts like a metronome, keeping the timing for when to change the light states.

Expected Outcomes

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

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

The success of the program will be determined by the behavior of the LEDs connected to Port A. The expected outcome is that the LEDs will blink on and off repeatedly, creating a visual indicator of the program in action. If the program functions correctly, you will observe a rhythm of light that gives a clear signal that the microcontroller is actively controlling the LED states.

Examples & Analogies

Consider the way a Christmas tree lights up during the holidays. If all the lights start blinking on and off systematically, it creates a festive and engaging display. Just like how you expect your holiday lights to work, in this experiment, we expect the LEDs to blink continuously to show that the system is functioning correctly.

Definitions & Key Concepts

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

Key Concepts

  • Control Word Configuration: Explanation of how to configure the 8255 using its control word.

  • Delay Functions: Understanding the importance and implementation of delays in assembly programming for perceivable output.

  • Main Loop Operations: The sequence of operations in the main loop for blinking LEDs using an assembly program.

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: 8AH.

  • Assembly code snippet for blinking LEDs: Load control word, output data to Port A, and implement a delay.

Memory Aids

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

🎵 Rhymes Time

  • To blink LEDs bright, ON and OFF at night, we load up with eight, to make the control word right.

📖 Fascinating Stories

  • Once upon a time in the land of circuits, a programmer wanted to make the LEDs dance. With the magic of 8AH, he waved his code wand, and the LEDs began to pulse with joy.

🧠 Other Memory Gems

  • Control word format: I (D7) 00 (M1, M0) Output (D4) Input (D3) 0 (Mode) 0 (Direction).

🎯 Super Acronyms

LEAD - Load, Enable, Activate, Delay for the LED blinking process.

Flash Cards

Review key concepts with flashcards.

Glossary of Terms

Review the Definitions for terms.

  • Term: PPI

    Definition:

    Programmable Peripheral Interface; a device that allows microprocessors to interact with peripheral devices.

  • Term: Control Word

    Definition:

    A byte that configures the operational modes of the 8255 PPI.

  • Term: Mode 0

    Definition:

    A basic I/O mode where all ports can be configured as simple latched outputs or buffered inputs.

  • Term: Subroutine

    Definition:

    A set of instructions designed to perform a frequently used operation within a program.

  • Term: Assembler

    Definition:

    A tool for converting assembly language into machine code.

  • Term: Accumulator

    Definition:

    A register in the CPU that temporarily stores data and results of operations.

  • Term: Delay

    Definition:

    A programmable interval that determines how long a specific state is maintained in the program.