Past exam question: Assignment 3, Q5(d)
Open in the Padhaiko appQuestion
A/D converter requires signal to start the conversion and indicates the completion of operation with the end of conversion signal.8255A PPI is interfaced with 8085 microprocessor at 80H. Microprocessor reads 8-bit output data of the ADC at port A and displays the same data to eight LEDs connected at port B of 8255A.state any assumptions made. d) Write a program to perform the operation.
Solution
Program Logic:
- Initialize the 8255A by writing control word
98Hto the Control Register (83H) so Port A = Input, Port B = Output, Port C Upper = Input (PC7= EOC), Port C Lower = Output (PC0= SOC). - Send a HIGH-to-LOW Start of Conversion (
SOC) pulse onPC0using BSR words01Hand00Hwritten to83H. - Poll Port C (
82H) and rotatePC7(EOC) into the Carry flag withRAL; loop whileCY = 0(assume EOC goes HIGH when conversion finishes). - Once
CY = 1, read the 8-bit ADC data from Port A (80H), output it to the LEDs on Port B (81H), and repeat continuously.
8085 Assembly Language Program:
START: MVI A, 98H ; Mode 0: PA=In, PCU=In (EOC), PB=Out (LEDs), PCL=Out (SOC)
OUT 83H ; Initialize 8255A Control Register
LOOP: MVI A, 01H ; BSR word: Set PC0 = 1 (Start of Conversion HIGH)
OUT 83H
CALL DELAY ; Short pulse width delay
MVI A, 00H ; BSR word: Reset PC0 = 0 (Start of Conversion LOW)
OUT 83H
CHECK: IN 82H ; Read Port C
RAL ; Shift bit 7 (EOC) into Carry flag
JNC CHECK ; Wait until EOC = 1 (conversion complete)
IN 80H ; Read 8-bit ADC output from Port A
OUT 81H ; Display data on 8 LEDs at Port B
JMP LOOP ; Repeat continuously
DELAY: MVI C, 0AH ; Short pulse-width delay
DLOOP: DCR C
JNZ DLOOP
RETAnswer:
The 8085 program initializes the 8255A at 83H with 98H, pulses PC0 via BSR commands (01H then 00H) to start conversion, polls PC7 (EOC) at Port C (82H) using RAL/JNC, reads the digital output from Port A (80H), and writes it to the eight LEDs on Port B (81H) in a continuous loop.