EMAC PRIMER Instruction Manual page 69

Table of Contents

Advertisement

LESSON 23: Using ADCIN (service 9)
NEW INSTRUCTIONS
STC
Make the carry flag 1. Only the carry flag is affected
JZ
<addr> op code = CA
If the Z flag is 1 start executing the instructions at the two byte address following the instruction, otherwise
start executing the instruction after this one. The first byte following the op code is the least significant
byte of the address, the second byte is the most significant byte of the address. No flags are affected.
This lesson is intended to be used by those with experience in basic electronics. Please proceed to the next lesson if you
do not have basic electronics training.
This program will read the analog to digital convertor and then divide the number by 8 and produce a bar graph on the
digital output LEDs that is proportional to the analog input voltage.
A variable voltage source, ranging from 0 to +5 volts, must be connected to the analog input of the external digital I/O
connector CN3 (this is above and to the left of the ADDRESS/REGISTER PAIR displays). This can be simply done with a
10K potentiometer by connecting the wiper to the analog input and one of the other two connections to +5V and the other
to ground. Connector CN3 provides +5 volts on pin 22, analog input on pin 20 and ground on pin 18.
Be sure there is no power to the PRIMER when connecting the potentiometer to the I/O connector. Also be sure that you
do not short any of the connections when connecting the potentiometer to CN3. It may be best to use a mating connector,
or to wire wrap the connections. Once the proper connections have been made and checked, apply power to the PRIMER
and load the following program.
leds
equ
mos
equ
org
start:
mvi
call
mov
rrc
rrc
rrc
ani
jz
mov
mvi
loop:
stc
rar
dcr
jnz
zerout:
out
jmp
end
ADDRESS
FF01
FF02
FF03
FF04
FF05
FF06
FF07
FF08
FF09
FF0A
FF0B
FF0C
FF0D
FF0E
FF0F
continued on next page...
op code = 37
11h
; output port for digital output LEDs
1000h
; MOS CALL address
0ff01h
; start address of program
c,9
; service 9
mos
; get ADC
a,l
; put in A register
; rotate A right = divide by 2
; divide by 2
; divide by 2
00011111b
; remove upper 3 bits
zerout
; if A = 0 then send it out
c,a
; c=number of LEDs to light up
a,0
; A=0
; set carry
; and rotate it into A register
c
; decrement the counter
loop
; if c > 0, loop again
leds
; send bar pattern to LEDs
start
; do it all again
DATA
INSTRUCTION
0E
MVI
C,9
09
CD
CALL 1000h
00
10
7D
MOV
A,L
0F
RRC
0F
RRC
0F
RRC
E6
ANI
01FH
1F
CA
JZ
FF18
18
FF
4F
MOV
C,A
69

Advertisement

Table of Contents
loading

Table of Contents