Program 2: Blinking LEDs Connected to Port A - 4.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 Control Words

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Today, we will learn about control words used in the 8255 to configure our ports. Can anyone tell me what a control word is?

Student 1
Student 1

Is it the command we send to the PPI to tell it how we want to configure the ports?

Teacher
Teacher

Exactly! The control word defines how we use each port. For our LED blinking example, we set Port A to output. What binary value do we use for this?

Student 2
Student 2

I think we set D4 to 0 for output.

Teacher
Teacher

That's right! The full control word is crucial for ensuring that everything works as expected. Remember it as `I/O mode - Direction - Modes`. This way, we can keep track of our settings easily.

Student 3
Student 3

Could you repeat how we derived the control word for our program?

Teacher
Teacher

Sure! We checked each bit position for Port A, B, and C’s modes and directions. The final control word for our use case is `8AH` which represents our choices.

Student 4
Student 4

So it's like giving instructions to the 8255 on how to behave?

Teacher
Teacher

Exactly! By sending this control word, we define how the ports will interact with devices attached to them.

Teacher
Teacher

Let's recap: Control words set port modes and directions, and the control word for our example is `8AH`. Great job today!

Writing the Assembly Program

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Now that we have our control word, let’s look at the assembly language program for blinking LEDs. What’s our first step?

Student 1
Student 1

We need to initialize the 8255 with the control word.

Teacher
Teacher

Correct! We do this using the `OUT` instruction. Which address do we send our control word to?

Student 2
Student 2

To address `83H` for the Control Word Register.

Teacher
Teacher

Exactly! After initialization, we enter our main loop. Can anyone describe what happens there?

Student 3
Student 3

We load `FFH` to turn the LEDs ON, then we output it to Port A.

Teacher
Teacher

Yes! And after that, we call a delay. This delay keeps the LEDs ON for how long?

Student 4
Student 4

Long enough for us to see them lit, before we turn them OFF with `00H`.

Teacher
Teacher

Right! Now let’s remember to include a return to the start of the loop so it keeps repeating. And this cycle gives us the blinking LEDs effect!

Teacher
Teacher

Remember, the blinking program consists of initializing the PPI, turning on the LEDs, waiting, turning them off, and looping back. Great engagement today!

Explaining the Delay Function

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Let’s explore the delay subroutine in our program. Why do we need a delay between turning LEDs ON and OFF?

Student 1
Student 1

To make sure we can see the LEDs blinking, otherwise it would be too fast.

Teacher
Teacher

Exactly! This part of the program controls how long we see the LEDs in each state. How is this delay implemented in assembly?

Student 2
Student 2

We use loops that decrement registers until they reach zero.

Teacher
Teacher

Great! We load particular registers, decrement them until they hit zero, and this helps us achieve a controlled delay. Can anyone think of what would happen if we set the values too low?

Student 3
Student 3

The blinking would be too fast for the human eye to see.

Teacher
Teacher

Correct! That would defeat the purpose of blinking LEDs. Always optimize with appropriate values for visibility.

Teacher
Teacher

To recap, the delay subroutine is essential for making our LED blinking visible, and it achieves this via decrement loops. Nice work today, everyone!

Introduction & Overview

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

Quick Overview

This section covers how to configure the 8255 Programmable Peripheral Interface for blinking LEDs connected to Port A, utilizing assembly programming.

Standard

In this section, students learn to write an assembly program that sets up the 8255 PPI to control LEDs on Port A. The program continuously turns the LEDs on and off, illustrating the principles of output port configuration and control word usage.

Detailed

Section 4.2: Blinking LEDs Connected to Port A

This section details the process of configuring the 8255 Programmable Peripheral Interface (PPI) to blink LEDs attached to Port A of an 8085 microprocessor. The objective is to enable the LEDs to turn ON and OFF in a loop, effectively demonstrating the capabilities of the PPI in managing output devices.

Setup and Control Word Calculation

To begin with, the PPI is initialized to operate in Mode 0. The control word for this mode is calculated based on the desired configuration for the output and input ports:
- D7: Indicates I/O mode (set to 1).
- D6 and D5: Define Group A mode, set to 00 for Mode 0.
- D4: Specifies Port A direction, set to output (0).
- D0: Determines the direction for Port C lower, which is arbitrarily set to output.

The final control word calculated is 8AH (in hexadecimal).

Assembly Program Overview

The program outline involves the following steps:
1. Initialize the 8255 PPI by writing the control word to the Control Word Register.
2. Enter a loop where:
- The accumulator is loaded with FFH to turn ON all LEDs.
- The data is outputted to Port A.
- A delay is invoked to keep the LEDs on for a while.
- The accumulator is set to 00H to turn the LEDs OFF.
- Another delay is called.
3. The loop repeats, creating a blinking effect on the LEDs.

The code fragments provided in this section illustrate how to manage these operations, ensuring that students understand both the programming logic and the principles behind port interfacing using the 8255 PPI.

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 main goal of this program is to make LEDs turn on and off repeatedly using the 8255 Programmable Peripheral Interface. The LEDs are connected to Port A of the 8255, which we will set as an output port. By configuring Port A appropriately, we can control the state of the LEDs in a simple and clear manner.

Examples & Analogies

Think of it like a traffic light that turns red for a few seconds and then green for a few seconds. Just like how a traffic light blinks to control traffic, this program will blink LEDs to indicate an on/off status.

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 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) (Same as previous if this config works)

Detailed Explanation

The control word is crucial for setting up the 8255. Here is how each bit in the control word corresponds to the desired configuration:
- D7 is set to 1 to indicate we are configuring the ports for I/O operations.
- D6 and D5 are set to 00 to choose Mode 0, which is a basic I/O mode.
- D4 specifies that Port A is an output (0 means output).
- D3 designates Port C upper as an input, although it won’t be used in this program.
- D2 sets Group B to Mode 0, while D1 and D0 set Port B and the lower part of Port C as inputs and outputs respectively.
Thus, when we combine these bits, we get 8AH in hexadecimal, which we will send to the Control Word Register.

Examples & Analogies

Imagine a lighting system where you can decide whether each room should have its light turned on (output) or remain off (input). The 8AH control word functions like a smart control panel, allowing you to quickly set how each room’s lights (ports) will behave.

Assembly Code Overview

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 and sets up a continuous loop to blink the LEDs:
1. It starts at address 2000H.
2. It loads the control word (8AH) into the accumulator and outputs it to the Control Word Register (CWR) to set up the ports.
3. The main loop begins where it first turns all LEDs ON by loading FFH into the accumulator and sending it to Port A.
4. After a delay (controlled by the DELAY subroutine), it loads 00H to turn them OFF, and again waits.
5. The JUMP instruction keeps the blinking going indefinitely until the system is turned off.

Examples & Analogies

Consider this code like a simple automated lighting system where the lights (LEDs) are programmed to turn on and off in cycles. Each command to the lights is like sending a signal to say 'lights on' or 'lights off', with a pause in between calls to manage how long they stay in each state.

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

After executing the program successfully, the outcome should be that the LEDs lit connected to Port A of the 8255 will blink on and off repeatedly. The exact timing will depend on the delay chosen in the program, but the main point is that they should visibly toggle between being lit (ON) and unlit (OFF) in a continuous loop.

Examples & Analogies

This is akin to a party where the lights blink in rhythm to the music. If the LEDs are the party lights, you'll see them flash in a pattern - first dazzling bright, then dark, creating an engaging visual experience!

Definitions & Key Concepts

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

Key Concepts

  • Control Word: Defines operation modes and port configurations of the 8255.

  • Port A: Primary interface for outputting data, particularly for controlling LEDs.

  • Delay: Essential for visible blinking of LEDs, programmed through decrement loops.

  • Assembly Language: The coding format for instructing the microprocessor.

Examples & Real-Life Applications

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

Examples

  • The process of initializing Port A for output to blink a set of LEDs involves sending a specific control word to the 8255.

  • A control word of 8AH sets up Port A as output while the delay creates a visible ON/OFF pattern for the LEDs.

Memory Aids

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

🎵 Rhymes Time

  • When LEDs blink, they fill us with cheer, a pause in-between keeps them solid and clear.

📖 Fascinating Stories

  • In a microcontroller world, a brave little LED wanted to dance. It needed a command known as a control word to make its moves shine bright, a delay to catch the audience’s eye, and a loop to keep repeating this joyful show.

🧠 Other Memory Gems

  • Acronym 'B.L.I.N.K' can help: 'B' - Blink, 'L' - Loop, 'I' - Initialize, 'N' - Numbers for delay, 'K' - Keep ON/OFF pattern.

🎯 Super Acronyms

Use the acronym 'P.A.D'

  • 'P' for Port
  • 'A' for Active
  • and 'D' for Direction to remember port configurations.

Flash Cards

Review key concepts with flashcards.

Glossary of Terms

Review the Definitions for terms.

  • Term: Control Word

    Definition:

    An 8-bit command sent to the 8255 to configure its operating modes and port directions.

  • Term: Port A

    Definition:

    An 8-bit I/O port on the 8255 that can be set as input or output.

  • Term: Mode 0

    Definition:

    A basic input/output mode of 8255 that allows all ports to function as simple latched inputs or outputs.

  • Term: LED

    Definition:

    Light Emitting Diode; a semiconductor device that emits light when an electric current passes through it.

  • Term: Assembly Code

    Definition:

    A human-readable representation of machine code instructions.

  • Term: Delay Subroutine

    Definition:

    A sequence of instructions used to create a pause between actions in a program.