Saturday, September 26, 2009
8085 programming (part3)
PROGRAMS IN INTERFACING & APPLICTIONS
I. Interfacing with IC 8251(Serial Communcation/USART)
Statement: Write a program to output contents of B register LSB to MSB on the SOD pin.
Source program:
MVI C, 08H : Initialize count with 8
MOV A, B
BACK: RRC : Rotate B register contents right
MOV B, A : Save contents of register B
JNC SKIP : If no carry skip
MVI A, COH
SIM : If carry, send high on SOD
JMP NEXT
SKIP: MVI A, 40H
SIM : If no carry, send low on SOD.
NEXT: CALL DELAY : Wait for specific time
DCR C : Decrement count by 1
JNZ BACK : if count = 0 Stop, if not repeat
HLT : Stop program execution
Delay subroutine:
Delay: LXI D, Count
Back: DCX D
MOV A, D
ORA E
JNZ Back
RET
Flowchart for Source Program:
Flowchart for Delay routine:
Statement: Write a program to output square wave of 1 kHz frequency on the SOD pinof 8085 for 5 seconds. Operating frequency of 8085 is 2 MHz.
Source program
LXI SP, 27FFH : Initialize stack pointer
LXI B, 1388H : Initialize counter with count 5000.
BACK: MVI A, COH
SIM : Send high on SOD pin
CALL DELAY : Wait for 0.5 msec
MVI A, 40H : Send low on SOD pin
CALL DELAY : wait for. 5 msec
DCX B : Decrement count by 1
MOV A, C
ORA B : Check if count = 0
JNZ BACK : If not, repeat
HLT : Stop program execution
Delay subroutine:
Delay: LXI D, Count
Back: DCX D
MOV A, D
ORA E
JNZ Back
RET
Flowchart for Source Program:
Statement: An ASCII character is being received on SID pin of 8085. Write a program in assembly language of 8085 to assemble this character and store it in memory. Write comment for each instruction.
Source program:
LXI SP, 27FFH
LXI H, 2000H : Memory pointer
RIM : Read SID
ANI 80H : Check D7 bit of Accumulator
CALL Delay : 1/2 bit time delay for stop bit
MVI B, 08H : Initialize bit counter
MVI D, 00H : Clear data register
UP1: ALL Delay : 1 bit time
RIM : Read SID line
ANI 80H : Mask bits B6 - Bo
ORA D : OR data bit with previous bits
RRC
MOV D, A : Store data bit at appropriate position
DCR B
JNZ UP1
RLC : Shift left to correct result
MOV M, A : Store result
RIM : Read stop bit
ANI 8OH
CZ error : If not stop bit call error
HLT : Terminate program.
Delay subroutine:
Delay: LXI D, Count
Back: DCX D
MOV A, D
ORA E
JNZ Back
RET
Flowchart for Source Program:
Flowchart for Delay routine:
Statement: Write a assembly program to transmit a message from an 8085 to a CRT terminal for the following requirements and draw the interfacing diagram.
i) A message of 50 characters is stored as ASCII characters (without parity) in memory locations starting at 2200H.
ii) Baud rate x 16
iii) Stop bits 2
Source program:
LXI H, 2200H : Initialize memory pointer to pointer the message
MVI C, 32H : Initialize counter to send 50 characters
MVI A, 00H
OUT FFH
OUT FFH : Dummy mode word
OUT FFH
MVI A, 40H : Reset command word
OUT FFH : Reset 8251A
MVI A, CAH : Mode word initialization
OUT FFH
MVI A, 11H : Command word initialization
OUT FFH
CHECK: IN FFH
ANI 0lH : Check TxRDY
JZ CHECK : Is TxRDY I? if not, check again
MOV A, M : Get the character in accumulator
OUT FEH : Send character to the transmitter
INX H : Increment memory pointer
DCR C : Decrement counter
JNZ CHECK : if not zero, send next character
HLT : Stop program execution
Statement: Write a assembly program to receive 25 bytes from an CRT terminal to 8085 for the following requirements.
i) Baud rate x 16
FLOWCHART
Labels: 8085, assembly language, microprocessors
Subscribe to Posts [Atom]