Past exam question: Assignment 3, Q8
Open in the Padhaiko appQuestion
Write a program for the 8085 µp to generate a square wave signal at the output of DAC.
Solution
Operating Principle and Assumptions:
- Assume an 8-bit DAC (e.g., DAC0808/MC1408) is interfaced to Port A (
80H) of an 8255A PPI (Control Word Register at83H). - To generate a square wave with duty cycle:
- Output the minimum digital code
00H( or ) to Port A and hold for a delay . - Output the maximum digital code
FFH() to Port A and hold for the same delay . - Repeat indefinitely.
- Output the minimum digital code
- Control Word: Mode 0, all ports output .
8085 Assembly Language Program:
MVI A, 80H ; Mode 0: Configure Port A as Output
OUT 83H ; Initialize 8255A Control Register (83H)
LOOP: MVI A, 00H ; Load digital value for LOW level (0V)
OUT 80H ; Send to DAC via Port A (80H)
CALL DELAY ; Hold LOW state for half period (T/2)
MVI A, FFH ; Load digital value for HIGH level (+V_FS)
OUT 80H ; Send to DAC via Port A (80H)
CALL DELAY ; Hold HIGH state for half period (T/2)
JMP LOOP ; Repeat continuously
; --- Half-Period Delay Subroutine ---
DELAY: MVI C, FFH ; Load delay count (adjust for desired frequency)
D_LOOP: DCR C
JNZ D_LOOP
RETAnswer:
The 8085 program configures 8255 Port A (80H) as Mode 0 output using control word 80H at 83H, then alternates outputting 00H (LOW) and FFH (HIGH) to the DAC with an equal DELAY subroutine after each level to produce a continuous duty-cycle square wave.