Past exam question: Assignment 3, Q6
Open in the Padhaiko appQuestion
What will be the control word for interfacing as shown figure below? Also write the subroutine program to read the digital data from ADC.
Solution
Determining the 8255 Control Word and Port Addresses:
- Port Usage from the Schematic:
- Port A (
PA7–PA0): Configured as Input in Mode 0 (receives from the ADC804). - Port C Lower (
PC3–PC0): Configured as Input in Mode 0 (PC0monitors active-low from the ADC804). - Port B and Port C Upper (
PC7–PC4): Unused (configured as Output0by convention).
- Port A (
- Control Word Bit Assembly:
- (I/O Mode)
- (Group A Mode 0)
- (Port A = Input)
- (Port C Upper = Output, unused)
- (Group B Mode 0)
- (Port B = Output, unused)
- (Port C Lower = Input, for
PC0)
- Port Address Assumption: With tied to active-low ( selects 8255) and unused lines , the ports map to:
- Port A =
00H, Port B =01H, Port C =02H, Control Word Register =03H(note: if the bubble on represents an inverter so , these become80H–83H).
- Port A =
- ADC Clock Frequency:
How Conversion and Reading Work in This Circuit: Because of the ADC804 is grounded and its and pins are tied to the system and lines:
- Writing any dummy byte to Port A (
OUT 00H) asserts low, pulsing the ADC804's pin to start conversion (while the 8255 ignores the write since Port A is configured as Input). - The 8085 polls
PC0(IN 02H,RAR) until (), indicating conversion is complete. - Executing
IN 00Hasserts low, simultaneously enabling the ADC804 tri-state buffers ontoPA7–PA0and reading Port A into the 8085 accumulator.
8085 Subroutine to Read Digital Data from ADC804:
; Assumed port addresses (A7 = 0, A6..A2 = 0):
; Port A = 00H, Port C = 02H, Control Register = 03H
READ_ADC: MVI A, 91H ; Control word: Mode 0, PA=Input, PCL=Input (PC0=INTR')
OUT 03H ; Initialize 8255 Control Register
OUT 00H ; Pulse WR' low (with ADC CS'=0) to start ADC conversion
POLL: IN 02H ; Read Port C
RAR ; Move PC0 (INTR') into Carry flag
JC POLL ; If CY = 1 (INTR' high, busy), continue waiting
IN 00H ; Assert RD' low to enable ADC data and read Port A into A
RET ; Return with 8-bit converted value in AccumulatorAnswer:
- 8255 Control Word:
91H( — Mode 0, Port A = Input forD0–D7, Port C Lower = Input forPC0, Port B and Port C Upper = Output). - Subroutine: Initializes
03Hwith91H, triggers conversion viaOUT 00H(pulsing ), pollsPC0(IN 02H+RAR) until , and reads the 8-bit sample viaIN 00H.