---
title: "DAC square wave generation at 1 kHz"
subject: "Instrumentation II"
chapter: 4
key: "semester_5/instrumentation_ii:dac-square-wave-1khz"
source: https://www.bctengineer.com/q/semester_5/instrumentation_ii/dac-square-wave-1khz
site: BCT Engineering
---

# DAC square wave generation at 1 kHz

Instrumentation II · Chapter 4: Interfacing A/D And D/A Converters

- Asked in: 2072 Chaitra, 3+3 marks
- Video: [DAC INTERFACING-SQUARE WAVE GENERATION USING I/O MODE](https://www.youtube.com/watch?v=I0JjXCk0n6w) — S Nazeer Hussain
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/instrumentation_ii/dac-square-wave-1khz
- Whole chapter: https://www.bctengineer.com/md/semester_5/instrumentation_ii/chapter-4

## Question

Interface a suitable DAC using 8255 PPI to a 8085 microprocessor to generate a square wave oscillating between 0V and -5V having a frequency of 1 KHz. Show the interfacing circuit and the necessary program.

## Short answer

Use DAC0800 with two op-amps for 0 to -5V output; 8255 port A drives the DAC, control word 80H. A program sends 00H then FFH to port A with a delay loop (B=67H, 103 counts) giving 500 µs per level, producing a 1 kHz square wave.

## Answer

#### Choice of DAC and assumptions
An 8-bit **DAC0800** is used, followed by two op-amp stages (a current-to-voltage converter and a unity-gain inverter). Code 00H then gives 0 V and code FFH gives about -5 V (-4.98 V). The 8085 runs at 3 MHz (T = 0.333 us). The 8255 is I/O mapped at 80H-83H, and port A drives the DAC.

#### Interfacing circuit
```text
 8085 -- AD0-AD7, IOW', IOR', RESET, A0,A1, CS'(A7=1) -- 8255
 8255 PA0-PA7 --------> DAC0800 D7-D0 (digital input)
 DAC0800: Vref(+) = +5 V via 5 kohm, Vref(-) via 5 kohm to GND  (Iref = 1 mA)
          Iout (pin 4) --> op-amp 1 (741, +/-12 V) with Rf = 5 kohm
                           V1 = +5 V x N/256        (0 to +4.98 V)
          V1 --> op-amp 2, inverting stage (10 kohm / 10 kohm, gain -1)
                           Vout = -5 V x N/256      (0 to -4.98 V)
 N = 00H -> 0 V ;  N = FFH -> -4.98 V (about -5 V)
```
Control word: port A output, mode 0 (others unused): 1000 0000 = **80H**.

#### Timing calculation
For 1 kHz the period is 1 ms, so each level lasts 0.5 ms = 500 us = 1500 T-states at 3 MHz.
Per half-period: MVI A (7) + OUT (10) + CALL (18) + delay + JMP (10, once per cycle).
Delay routine: MVI B,n (7) + n x [DCR B (4) + JNZ (10)] - 3 + RET (10) = 14n + 14.
One half = 7 + 10 + 18 + 14n + 14 = 49 + 14n T-states. One cycle = 2 x (49 + 14n) + 10 = 108 + 28n.
For 3000 T-states (1 ms): 28n = 2892, n = 103.3. Take **n = 103 (67H)**, so the cycle is 2992 T = 997 us and the frequency is 1.003 kHz.

#### Program
```text
        MVI A,80H
        OUT 83H          ; port A output
START:  MVI A,00H        ; 0 V
        OUT 80H
        CALL DELAY
        MVI A,FFH        ; -5 V (full scale)
        OUT 80H
        CALL DELAY
        JMP START
DELAY:  MVI B,67H        ; n = 103
LOOP:   DCR B
        JNZ LOOP
        RET
```
Output: a square wave alternating between 0 V and about -5 V (-4.98 V) with 1 kHz frequency and 50% duty cycle.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. For a 1 kHz square wave with 50% duty cycle, how long must each level last?
   A. 500 us
   B. 1 ms
   C. 250 us
   D. 100 us
   Answer: A. Period is 1 ms, so each half is 0.5 ms = 500 us. (Key point: Half period)

2. With the described DAC0800 arrangement, what do codes 00H and FFH produce?
   A. -5 V and 0 V
   B. 0 V and about -5 V
   C. 0 V and +5 V
   D. +5 V and -5 V
   Answer: B. Vout = -5 V x N/255, so 00H gives 0 V and FFH gives about -5 V. (Key point: Output levels)

3. At 3 MHz, how many T-states make up the 1 ms period that the program must time?
   A. 1500
   B. 6000
   C. 300
   D. 3000
   Answer: D. 3 MHz means 3000 T-states per ms; each half is 1500 T-states. (Key point: T-states)

## Related in Instrumentation II

- [10-bit DAC triangular wave at 500 Hz](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Adac10-triangular-500hz) — Instrumentation II, chapter 4
- [8-channel ADC interface with 8255 and 8085](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Aadc8-8255-problem) — Instrumentation II, chapter 4
- [Interfacing 10-bit DAC with 8085](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Adac10-8085) — Instrumentation II, chapter 4, asked 2×
- [Double handshake data transfer with 8255-PPI](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Adouble-handshake-8255) — Instrumentation II, chapter 2
- [8255 at A0A0H: interface and control words](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Appi-a0a0h-control-words) — Instrumentation II, chapter 2
- [Interfacing ADC0808 with 8085 using 8255A](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Aadc0808-8255-interface) — Instrumentation II, chapter 4

## Related in other subjects

- [1 kHz square wave on P1.5 using timer](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-square-wave-timer) — Embedded System, chapter 9
- [Astable multivibrator for square wave generation](https://www.bctengineer.com/question.md?key=semester_3%2Felectronics_devices_and_circuit%3Aastable-multivibrator-square-wave) — Electronics Devices and Circuit, chapter 5
- [Square wave generator circuit](https://www.bctengineer.com/question.md?key=semester_3%2Felectronics_devices_and_circuit%3Asquare-wave-generator-circuit) — Electronics Devices and Circuit, chapter 5
- [8085 ALP: square of ten numbers](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-square-numbers) — Microprocessor, chapter 2
