Upload
nakranimahender
View
259
Download
2
Embed Size (px)
DESCRIPTION
8085 applications
Citation preview
The 8085 Applications
Measurement of Voltage/Current
For measuring voltage/current we need to interface ADC 0808 with 8085 using 8255. Let us use port A of 8255 for transferring digital data output of ADC to the CPU and port C for control signals.
Assume that an analog input is present at I/P2 of the ADC and a clock input of suitable frequency is available for ADC.
Since the analog input I/P2 is used and therefore address pins A,B,C should be 0,1,0 respectively to select I/P2.
The OE and ALE pins are already kept at +5V to select the ADC and enable the outputs.
Port C upper acts as the input port to receive the EOC signal while port C lower acts as the output port to send SOC to the ADC.
Measurement of Voltage/Current
This Configuration is shown in figure below
Measurement of Voltage/Current
The 8255 control word is written as follows:
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 1 1 0 0 0 = 98H
Measurement of Voltage/Current
The required ALP is as follows: MVI A, 98h ;initialize 8255 as OUT CWR ;discussed above. MVI A, 02h ;Select I/P2 as analog OUT Port B ;input. MVI A, 00h ;Give start of conversion OUT Port C ; pulse to the ADC MVI A, 01h OUT Port C MVI A, 00h OUT Port C
WAIT: IN Port C ;Check for EOC by reading port C upper RCR ;rotating through carry
JNC WAIT ;In no EOC, then check again IN Port A ;If EOC, read digital equivalent in A HLT ;Stop.
Measurement of Frequency
To evaluate frequency, the number of cycles/seconds has to be determined.
The signal input from the pulse generator is applied to SID line of the 8085. The RIM instruction reads the SID line and stores it in the 7th bit of accumulator.
The program detects the rising edge and subsequent falling edge of the signal. Once detected, it increments the count in HL pair, which is initialized to zero at the beginning. This way number of pulses is counted till the timer generates an interrupt to the processor.
The maximum delay produce by 8253 timer is 1/23 of second. The HL pair has number of pulses counted for 1/23 of second. Therefore, the content of HL pair is multiplied by 23 which gives total number of pulses per second.
The interrupt to processor is given through RST 5.5 line.
The Hardware configuration is shown below
The interrupt mask required is
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 1 1 1 1 0 = 1E
The CWR of timer required is
D7 D6 D5 D4 D3 D2 D1 D0
0 0 1 1 0 0 0 0 = 30H
The Program is given by
MVI A,30 ;Control word for timer
OUT CWR ;Port Addres of CWR of Timer
MVI A,FF ;Move LSB of the count to counter0
OUT CONT0 ;Port address of counter 0
MVI A,FF ;Move MSB of count to counter0
OUT CONT0 ;Port address of counter0
LXI H,0000 ;Clear HL pair for pulse count
EI ;Enable Interrupt
MVI A,1E ;Set RST5.5 SIM ;Set interrupt mask
Nohigh: RIM ;Identify low to high transition
ANI 80
CPI 80 ;Compare with 80
JC Nohigh ;If no transition look again
Nolow: RIM ;Identify high to low transition
ANI 80
CPI 80
JZ Nolow ;If no transition look again
INX H ;If transition completes increament pulse count
SHLD 4200 ;Store pulse count at 4200
JMP Nohigh ;Repeat for more pulse count
The ISR of RST5.5
002C: JMP 4300 ;jump to specific address
4300: LHLD 4200 ;Get the count of pulses in HL pair
XCHG ;Copy the count in DE pair
LXI H,0000 ;Clear HL pair
MVI B,17 ;Initialize B to 17H(23D)
Repeat: DAD D ;Add HL pair and DE pair
DCR B ;Decrement B
JNZ Repeat ;Multiplication by repeated addition
SHLD 4500 ;Store HL pair in 4500 and 4501
LDA 4501 ;start packed to unpacked conversion
ANI F0 ;AND to get the MSD
RRC ;Rotate to get the digit in right position
RRC
RRC
RRC
STA 4600 ;Store it at 4600
LDA 4501
ANI 0F ;AND to get LSD
STA 4601 ;Store it at 4601
LDA 4500 ;Get Lower significant two digits
ANI F0 ;AND to get the MSD
RRC ;Rotate to get the digit in right position
RRC
RRC
RRC
STA 4602 ;Store it at 4600
LDA 4500
ANI 0F ;AND to get LSD
STA 4603 ;Store it at 4601
LXI H,4600 ;Call Display routine to Display result
MVI A,03
MVI C,09 ;Segment Address
CALL 0005 ;Display Routine
HLT