0% found this document useful (0 votes)
16 views

Programmable Peripheral Devices

The document provides examples of configuring ports and control words for an 8255 chip. Example 1 shows setting up port A as input, port B as output, and ports C upper and lower in mode 0. Example 2 shows another port configuration in mode 0 and 1. Example 3 sets a specific bit on the bit set/reset register. Example 4 and 5 demonstrate timer configuration and generating a square wave.

Uploaded by

Tamal Singha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Programmable Peripheral Devices

The document provides examples of configuring ports and control words for an 8255 chip. Example 1 shows setting up port A as input, port B as output, and ports C upper and lower in mode 0. Example 2 shows another port configuration in mode 0 and 1. Example 3 sets a specific bit on the bit set/reset register. Example 4 and 5 demonstrate timer configuration and generating a square wave.

Uploaded by

Tamal Singha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Ex.

1: Configure Port A as i/p in Mode 0, Port B as o/p


in mode 0, Port C (Lower) as o/p and Port C (Upper) as
i/p ports.
Step 1: Required control word
D7 D6 D5 D4 D3 D2 D1 D0

1 0 0 1 1 0 0 0

Group A Group B
Mode Selection Port C (Lower)
00 = Mode 0 0 = OUTPUT
Port A Port B
1 = INPUT 0 = OUTPUT
Port C (Upper) Mode Selection
1 = INPUT 0 = Mode 0

The bit pattern 1 0 0 1 1 0 0 0 i.e 98H is to be sent to the


control word register of 8255
Step 2: Required address of Control Word Register (CWR)
A7 A6 A5 A4 A3 A2 A1 A0

0 0 1 0 0 0 1 1 = 23 H

Depends on the decoding logic Required to select CWR


Step 2: Required address of Control Word Register (CWR)
A7 A6 A5 A4 A3 A2 A1 A0

0 0 1 0 0 0 1 1 = 23 H

Depends on the decoding logic Required to select CWR

MOV A, #98H
MOV DPTR, #0023H
MOVX @DPTR, A
Ex. 2: Write initialization instruction for the 8255A to set
up Port A as an o/p port in Mode 0, Port B as o/p in mode
1 for interrupt I/O, Port C (upper) as o/p in Mode 0.

Step 1: Required control word


D7 D6 D5 D4 D3 D2 D1 D0

1 0 0 0 0 1 0 0

Group A Group B
Mode Selection Port C (Lower)
00 = Mode 0 0 = Don’t care
Port A Port B
0 = OUTPUT 0 = OUTPUT
Port C (Upper) Mode Selection
0 = OUTPUT 1 = Mode 1

The bit pattern 1 0 0 0 0 1 0 0 i.e 84H is to be sent to the


control word register of 8255A
Step 2: Required address of Control Word Register (CWR)

A7 A6 A5 A4 A3 A2 A1 A0

0 0 0 0 0 0 1 1 = 03 H

Depends on the decoding logic Required to select CWR

MOV A, #84H
MOV DPTR, #0003H
MOVX @DPTR, A
Ex 3. Write the BSR control word of 8255 to set bits PC7.

D7 D6 D5 D4 D3 D2 D1 D0

0 0 0 0 1 1 1 1

Bit Set/ Reset


BSR Mode 1 = SET
0 = SET

Don’t care

1/0

Select a bit

1 1 1 = PC7
Ex 4: Set Counter 0 of 8254 timer in Mode 1
D7 D6 D5 D4 D3 D2 D1 D0
Control Word 0 0 1 1 0 0 1 0
Register
= 32 H

Select 16 bit Select Binary


Counter 0 count Mode 0 count

A7 A6 A5 A4 A3 A2 A1 A0
Address of
Control Word 1 0 0 0 0 0 1 1 = 83 H
Register

User defined Select Control


Register
Commands

MOV A, #32 H
MOV DPTR, #0083 H
MOVX @DPTR, A
Ex 5: Generate a square wave of 1ms period using 8254
timer. The input frequency is 2MHz
D7 D6 D5 D4 D3 D2 D1 D0
Control Word 0 0 1 1 0 1 1 0 = 37 H

Select 16 bit Select Binary


Counter 0 count Mode 3 count

A7 A6 A5 A4 A3 A2 A1 A0
CWR 1 0 0 0 0 0 1 1 = 83 H
Counter 0 1 0 0 0 0 0 0 0 = 80 H

Counter = (1 x 10-3 ) x (2 x 106)


= 2000
= 07D0 H
Commands:
MOV A, #37 H
MOV DPTR, #0083 H
MOVX @DPTR, A
MOV A, #D0 H
MOV DPTR, #0080 H
MOVX @DPTR, A
MOV A, #07 H
MOVX @DPTR, A

You might also like