Saturday, September 26, 2009

 

8085 programming (part4)

  1. Initialize 8255

Statement: Write a program to initialize 8255 in the configuration given below

Sample 1:

Write a program to initialize 8255 in the configuration given below:

1. Port A: Simple input

2. Port B: Simple output

3. Port CL: Output

4. Port Cu: Input

Assume address of the control word register of 8255 as 83H.

Solution:

SOURCE PROGRAM 1:

MVI A, 98H : Load control word

OUT 83H : Send control word

Sample 2:

Write a program to initialize 8255 in the configuration given below:

1. Port A: Output with handshake

2. Port B: Input with handshake

3. Port CL: Output

4. Port Cu: Input

Assume address of the control word register of 8255 as 23H.

Solution:

SOURCE PROGRAM 2:

MVI A, AEH : Load control word

OUT 23H : Send control word

  1. Blink port C bit 0 of 8255
Statement: Write a program to blink Port C bit 0 of the 8255. Assume address of control word register of 8255 as 83H. Use Bit Set/Reset mode.

Source program:

BACK: MVI A, 0lH : Load bit pattern to make PCο high

OUT 83H : Send it to control word register

CALL DELAY : Call Delay subroutine

MVI A, 00H : Load bit pattern to make PCο Low

OUT 83H : Send it to control word register

CALL Delay : Call Delay subroutine

JMP BACK : Repeat

Delay subroutine:

Delay: LXI D, Count

Back: DCX D

MOV A, D

ORA E

JNZ Back

RET

FLOWCHART



  1. Flashing of LEDs

Statement: Design a system (both Software and Hardware) that will cause 4 LEDs to flash 10 times when a push button switch is pressed. Use 8255. Assume persistence of vision to be 0.1 seconds.

Source program:

LXI SP, 2000 H : Initialize stack pointer

MVI A, 90H

OUT CR : Initialize 8255

BACK: IN PA : [Read status

ANI 01 : of push

JNZ BACK : button]

MVI B, 0AH : Initialize counter

AGAIN: MVI A, 00H : Load data to light LEDs

OUT PC : Send data on port C

CALL Delay : Call. Delay of 0.1 sec

MVI A, FFH : Load data to switch off LEDs

OUT PC : Send data on port C

CALL Delay : Call Delay of 0.1 sec

DCR B : Decrement count

JNZ AGAIN : If not zero repeat

JMP BACK : Jump back to read status

Delay subroutine:

Delay: LXI D, Count

Back: DCX D

MOV A, D

ORA E

JNZ Back

RET

INTERFACING SCHEME


  1. Traffic Light Control

Statement: Design a microprocessor system to control traffic lights. The traffic light arrangement is as shown in Fig. The traffic should be controlled in the following manner.

1) Allow traffic from W to E and E to W transition for 20 seconds. 2) Give transition period of 5 seconds (Yellow bulbs ON) 3) Allow traffic from N to 5 and 5 to N for 20 seconds 4) Give transition period of 5 seconds (Yellow bulbs ON) 5) Repeat the process.

HARDWARE FOR TRAFFIC LIGHT CONTROL

Fig. shows the interfacing diagram to control 12 electric bulbs. Port A is used to control lights on N-S road and Port B is used to control lights on W-E road. Actual pin connections are listed in Table 1 below.

The electric bulbs are controlled by relays. The 8255 pins are used to control relay on-off action with the help of relay driver circuits. The driver circuit includes 12 transistors to drive 12 relays. Fig. also shows the interfacing of 8255 to the system.

INTERFACING DIAGRAM

SOFTWARE FOR TRAFFIC LIGHT CONTROL



Source program:

MVI A, 80H : Initialize 8255, port A and port B

OUT 83H (CR) : in output mode

START: MVI A, 09H

OUT 80H (PA) : Send data on PA to glow R1 and R2

MVI A, 24H

OUT 81H (PB) : Send data on PB to glow G3 and G4

MVI C, 28H : Load multiplier count (40ıο) for delay

CALL DELAY : Call delay subroutine

MVI A, 12H

OUT (81H) PA : Send data on Port A to glow Y1 and Y2

OUT (81H) PB : Send data on port B to glow Y3 and Y4

MVI C, 0AH : Load multiplier count (10ıο) for delay

CALL: DELAY : Call delay subroutine

MVI A, 24H

OUT (80H) PA : Send data on port A to glow G1 and G2

MVI A, 09H

OUT (81H) PB : Send data on port B to glow R3 and R4

MVI C, 28H : Load multiplier count (40ıο) for delay

CALL DELAY : Call delay subroutine

MVI A, 12H

OUT PA : Send data on port A to glow Y1 and Y2

OUT PB : Send data on port B to glow Y3 and Y4

MVI C, 0AH : Load multiplier count (10ıο) for delay

CALL DELAY : Call delay subroutine

JMP START

Delay Subroutine:

DELAY: LXI D, Count : Load count to give 0.5 sec delay

BACK: DCX D : Decrement counter

MOV A, D

ORA E : Check whether count is 0

JNZ BACK : If not zero, repeat

DCR C : Check if multiplier zero, otherwise repeat

JNZ DELAY

RET : Return to main program

  1. Stepper Motor Control

Statement: Interface a Stepper Motor to the 8085 microprocessor system and write an 8085 assembly language program to control the Stepper Motor.

HARDWARE FOR STEPPER MOTOR CONTROL

A stepper motor is a digital motor. It can be driven by digital signal. Fig. shows the typical 2 phase motor rated 12V /0.67 A/ph interfaced with the 8085 microprocessor system using 8255. Motor shown in the circuit has two phases, with center-tap winding. The center taps of these windings are connected to the 12V supply. Due to this, motor can be excited by grounding four terminals of the two windings. Motor can be rotated in steps by giving proper excitation sequence to these windings. The lower nibble of port A of the 8255 is used to generate excitation signals in the proper sequence. These excitation signals are buffered using driver transistors. The transistors are selected such that they can source rated current for the windings. Motor is rotated by 1.80 per excitation.

INTERFACING SCHEME

SOFTWARE FOR STEPPER MOTOR CONTROL

As port A is used as an output port, control word for 8255 is 80H.

Stepper Motor Control Program:

6000H Excite code DB 03H, 06H,

09H, OCH : This is the code sequence for clockwise rotation

Subroutine to rotate a stepper motor clockwise by 360° - Set the counts:

MVI C, 32H : Set repetition count to 50ıο

START: MVI B, 04H : Counts excitation sequence

LXI H, 6000H : Initialize pointer

BACK1: MOV A, M : Get the Excite code

OUT PORTA : Send Excite code

CALL DELAY : Wait

INX H : Increment pointer

DCR B : Repeat 4 times

JNZ BACK1


Delay subroutine:

Delay: LXI D, Count

Back: DCX D

MOV A, D

ORA E

JNZ Back

RET

FLOWCHARTS



Source Program

Stepper motor subroutine

Delay routine

  1. Seven Segment Display Interface (Eight Digits)

Statement: Interface an 8-digit 7 segment LED display using 8255 to the 8085 microprocessor system and write an 8085 assembly language routine to display message on the display.

HARDWARE FOR EIGHT DIGIT SEVEN SEGMENT DISPLAY INTERFACE

Fig. shows the multiplexed eight 7-segment display connected in the 8085 system using 8255. In this circuit port A and port B are used as simple latched output ports. Port A provides the segment data inputs to the display and port B provides a means of selecting a display position at a time for multiplexing the displays. A0-A7 lines are used to decode the addresses for 8255. For this circuit different addresses are:

PA = 00H PB = 01H

PC = 02H CR = 03H.

The register values are chosen in Fig. such that the segment current is 80 mA. This current is required to produce an average of 10 mA per segment as the displays are multiplexed. In this type of display system, only one of the eight display position is 'ON' at any given instant. Only one digit is selected at a time by giving low signal on the corresponding control line. Maximum anode current is 560 mA (7-segments x 80 mA = 560 mA), but the average anode current is 70 mA.

INTERFACING SCHEME

SOFTWARE FOR EIGHT DIGIT SEVEN SEGMENT DISPLAY INTERFACE


For 8255, Port A and B are used as output ports. The control word format of 8255 according to hardware connections is:

Source program:

SOFTWARE TO INITIALIZE 8255:

MVI A, 80H : Load control word in AL

OUT CR : Load control word in CR

SUBROUTINE TO DISPLAY MESSAGE ON MULTIPLEXED LED DISPLAY:

SET UP REGISTERS FOR DISPLAY:

MVI B, 08H : load count

MVI C, 7FH : load select pattern

LXI H, 6000B : starting address of message

DISPLAY MESSAGE:

DISP 1: MOV A, C : select digit

OUT PB

MOV A, M : get data

OUT PA : display data

CALL DELAY : wait for some time

DISP 1: MOV A, C

RRC

MOV C, A : adjust selection pattern

INX H

DCR B : Decrement count

JNZ DISP 1 : repeat 8 times

RET

Note: This "display message subroutine" must be called continuously to display the 7-segment coded message stored in the memory from address 6000H.

Delay subroutine:

Delay: LXI D, Count

Back: DCX D

MOV A, D

ORA E

JNZ Back

RET

Interfacing with IC 8279 (Keyboard and Display Controller)

  1. 8 x 8 Keyboard Interface(Without Interrupt signal)

Statement: Interface an 8 x 8 matrix keyboard to 8085 through 8279 in 2-key lockout mode and write an assembly language program to read keycode of the pressed key. The external clock frequency is 2MHz. Use I/O mapped I/O technique. (Dont use any Interrupts)

HARDWARE FOR 8 x 8 MATRIX KEYBOARD INTERFACE

SOFTWARE FOR 8 x 8 MATRIX KEYBOARD INTERFACE


The three steps needed to write the software are:

Step 1: Find keyboard/display command word.

Step 2: Find program clock command word

Step 3: Find Read FIFO/sensor RAM command word.

Source program:

MVI A, 00H : Initialize keyboard/display

OUT 81H : in encoded scan keyboard-2 keylockout mode

MVI A, 34H

OUT 81H : Initialize prescaler count

BACK: IN 81H : Read FIFO status word

ANI 07H : Mask bit B3 to B7

JZ BACK : If 0, key is not pressed wait for key press else read FIFO RAM

MVI A, 40H : Initialize 8279 in read

OUT 81H : FI FO RAM mode

IN 80H : Read FIFO RAM (keycode)

HLT : Stop program execution.

FLOWCHART



  1. 8 x 8 Keyboard Interface(With Interrupt signal)

Statement: Interface an 8 x 8 matrix keyboard to 8085 through 8279 in 2-key lockout mode and write an assembly language program to read keycode of the pressed key. The external clock frequency is 2MHz. Use I/O mapped I/O technique.

HARDWARE FOR 8 x 8 MATRIX KEYBOARD INTERFACE(With Interrupt)

Fig. shows the interfacing of 8 x 8 matrix keyboard in interrupt driven keyboard mode. In the interrupt driven mode interrupt line from 8279 is connected to the one of the interrupt input of 8085 except INTR. Here, INT line from 8279 is connected to the interrupt RST 7.5 of 8085. Other signal connections are same as in the non interrupt mode.

SOFTWARE FOR 8 x 8 MATRIX KEYBOARD INTERFACE(With Interrupt)


The three steps needed to write the software are:

Step 1: Find keyboard/display command word.

Step 2: Find program clock command word

Step 3: Find Read FIFO/sensor RAM command word.

Source program:

MVI A, 00H : Initialize keyboard/display in encoded

OUT 81H : scan keyboard 2 key lockout mode

MVI A, 34H

OUT 81H : Initialize prescaler count

MVI A, 0BH : Load mask pattern to enable RST 7.5

SIM : mask other interrupts

EI : Enable Interrupt

HERE: JMP HERE : Wait for the interrupt

Interrupt Subroutine:

MVI A, 40H : Initialize 8279 in read FIFO

OUT 81H : RAM mode

IN 80H : Read FIFO RAM (keycode)

EI : Enable Interrupt

RET : Return to main program

Note: In the interrupt driven keyboard, when key is pressed, key code is loaded into FIFO RAM and interrupt is generated. This interrupt signal is used to tell CPU that there is a keycode in the FIFO RAM. CPU then initiates read command with in the interrupt service routine to read key code from the FIFO RAM.

FLOWCHART



  1. 8 x 4 Matrix Keyboard Interface

Statement: Interface an 8 x 4 matrix keyboard to 8085 through 8279.

HARDWARE FOR INTERFACING 8x4 MATRIX KEYBOARD

Fig. Interfacing 8 x 4 keyboard matrix in decoded scan keyboard mode.

NOTE: As keyboard is having 8 rows and 4 columns, only 4 scan lines are required and we can avoid external decoder to generate scan lines by selecting decoded scan keyboard mode.

SOFTWARE FOR INTERFACING 8x4 MATRIX KEYBOARD

Source program:

MVI A, 00H : Initialize keyboard/display in encoded

OUT 81H : scan keyboard 2 key lockout mode

MVI A, 34H

OUT 81H : Initialize prescaler count

MVI A, 0BH : Load mask pattern to enable RST 7.5

SIM : mask other interrupts

EI : Enable Interrupt

HERE: JMP HERE : Wait for the interrupt

Interrupt Subroutine:

MVI A, 40H : Initialize 8279 in read FIFO

OUT 81H : RAM mode

IN 80H : Read FIFO RAM (keycode)

EI : Enable Interrupt

RET : Return to main program

  1. Interfacing of eight 7-segment digits

Statement: Interface 8/7-segment digits (common cathode) to 8085 through 8279 and write an 8085 assembly language program to display 1 to 8 on the eight seven segment digits. External clock frequency is 3 MHz.

HARDWARE FOR EIGHT SEVEN SEGMENT DIGITS INTERFACE

Fig. shows the interfacing of eight 7-segment digits to 8085 through 8279. As shown in the figure eight display lines (Bo-B3 and Ao-A3) are buffered with the help of transistor and used to drive display digits. These buffered lines are connected in parallel to all display digits. So, Sl and S2 lines are decoded and decoded lines are used for selection of one of the eight digits.

SOFTWARE FOR EIGHT SEVEN SEGMENT DIGITS INTERFACE


To display 1 to 8 numbers on the eight 7-segment digits we have to load 7-segment codes for 1 to 8 numbers in the corresponding display locations.

The three steps needed to write the software are:

Step 1: Find keyboard/display command word.

Step 2: Find program clock command word

Step 3: Find display RAM command word.

Source program:

LXI B, 6200B : Initialize lookup table pointer

MVI C, 08H : Initialize counter

MVI A, 00H : Initialize keyboard/display

OUT 8IH : Mode

MVI A, 3EH : Initialize prescaler count

OUT 8IH

MVI A, 90H : Initial size 8279 in write Display

OUT 8IH : RAM-mode

BACK : MOV A, M : Get the 7-segment code

OUT 80H : Write 7-segment code in display RAM

INX H : Increment lookup table pointer

DCR C : Decrement counter

JNZ BACK : if count = 0 stop, otherwise go to back

HLT : Stop program execution

FLOWCHART



LOOK UP TABLE



  1. Interfacing of 4x4 matrix keyboard and 4 digit 7 segment display

Statement: Interface 4 x 4 matrix keyboard and 4 digit 7-segment display and write an tssembly language program to read keycode of the pressed key and display same key on :he 7 segment display.

HARDWARE FOR 4x4 MATRIX KEYBOARD & 4 DIGIT 7 SEGMENT DISPLAY INTERFACE

Fig. shows interfacing diagram. Here, 4 scan lines are sufficient to scan matrix keyboard and to select display digits. Hence decoded mode is used.

SOFTWARE FOR 4x4 MATRIX KEYBOARD & 4 DIGIT 7 SEGMENT DISPLAY INTERFACE


The three steps needed to write the software are:

Step 1: Find keyboard/display command word.

Step 2: Find program clock command word

Step 3: Find Read FIFO RAM command word.

Step 3: Find Write FIFO RAM command word.

Source program:

MVI A, 00H : Initialize keyboard/display in encoded

OUT 81H : scan keyboard 2 key lockout mode

MVI A, 34H

OUT 81H : Initialize prescaler count

MVI A, 0BH : Load mask pattern to enable RST 7.5

SIM : mask other interrupts

EI : Enable Interrupt

HERE: JMP HERE : Wait for the interrupt

Interrupt service routine

MVI A, 40H : Initialize 8279 in read FIFO RAM mode

OUT 81H

IN 80H : Get keycode

MVI H, 62H : Initialize memory pointer to point

MOV L, A : 7-Segment code

MVI A, 80H : Initialize 8279 in write display RAM mode

OUT 81H

MOV A, M : Get the 7 segment code

OUT 80H : Write 7-segment code in display RAM

EI : Enable interrupt

RET : Return to main program

FLOWCHARTS

Source Program and Interrupt Service Routine



  1. Roll a message - 'HELL0123'

Statement: Write an assembly language program to roll message 'HELL0123' from right to left

HARDWARE FOR ROLLING HELLO123

Fig. shows the interfacing of eight 7-segment digits to 8085 through 8279. As shown in the figure eight display lines (Bo-B3 and Ao-A3) are buffered with the help of transistor and used to drive display digits. These buffered lines are connected in parallel to all display digits. So, Sl and S2 lines are decoded and decoded lines are used for selection of one of the eight digits.

SOFTWARE FOR ROLLING HELLO123


To roll above message we have to load 7-segment codes for characters within the message and it is necessary to configure 8279 in right entry mode

The three steps needed to write the software are:

Step 1: Find keyboard/display command word.

Step 2: Find program clock command word

Step 3: Find display RAM command word.

Clear command word.

Source program:

LXI B, 6200B : Initialize lookup table pointer

MVI C, 08H : Initialize counter

MVI A, 10H : Initialize keyboard/display in right entry mode

OUT 8IH : Mode

MVI A, 3EH : Initialize prescaler count

OUT 8IH

MVI A, D0H : Clear Display

OUT 8IH

MVI A, 90H : Initialize 8279 in write display

OUT 81H : RAM mode

BACK : MOV A, M : Get the 7-segment code

OUT 80H : Write 7-segment code in display RAM

INX H : Increment lookup table pointer

DCR C : Decrement counter

JNZ BACK : if count = 0 stop, otherwise go to back

HLT : Stop program execution

FLOWCHART



LOOK UP TABLE


  1. Roll your NAME

Statement: Write an assembly language program to your name from right to left

HARDWARE FOR ROLLING HELLO123

Fig. shows the interfacing of eight 7-segment digits to 8085 through 8279. As shown in the figure eight display lines (Bo-B3 and Ao-A3) are buffered with the help of transistor and used to drive display digits. These buffered lines are connected in parallel to all display digits. So, Sl and S2 lines are decoded and decoded lines are used for selection of one of the eight digits.

SOFTWARE FOR ROLLING THE NAME - J.BINU


To roll the above namewe have to load 7-segment codes for characters within the message and it is necessary to configure 8279 in right entry mode

The three steps needed to write the software are:

Step 1: Find keyboard/display command word.

Step 2: Find program clock command word

Step 3: Find display RAM command word.

Clear command word.

Source program:

LXI B, 6200B : Initialize lookup table pointer

MVI C, 08H : Initialize counter

MVI A, 10H : Initialize keyboard/display in right entry mode

OUT 8IH : Mode

MVI A, 3EH : Initialize prescaler count

OUT 8IH

MVI A, D0H : Clear Display

OUT 8IH

MVI A, 90H : Initialize 8279 in write display

OUT 81H : RAM mode

BACK : MOV A, M : Get the 7-segment code

OUT 80H : Write 7-segment code in display RAM

INX H : Increment lookup table pointer

DCR C : Decrement counter

JNZ BACK : if count = 0 stop, otherwise go to back

HLT : Stop program execution

FLOWCHART



LOOK UP TABLE



Labels: , ,


Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]