Saturday, September 26, 2009

 

8085 programming (part3)






PROGRAMS IN INTERFACING & APPLICTIONS

 

I. Interfacing with IC 8251(Serial Communcation/USART)

 

  1. Output byte from SOD pin

 

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:

 

 

 

  1. Generate square wave from SOD pin

 

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:

 

 

Flowchart for Delay routine:
 

 

 

  1. Receive ASCII character through SID pin

 

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:

 

 

  1. Transmit message using 8251

 

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

 

Solution Description:

  • CRT terminal uses normal RS 232C standard serial communication interface. Therefore, to transmit data to CRT it is necessary to have RS 232C interface at the sending end.
  • Fig. shows the interfacing of 8251 with RS 232C to 8085.
  • As shown in the Fig. three RS-232C signals (TxD, RxD are Ground) are used for serial communication between the CRT terminal and the 8085 system.
  • Line drivers and receivers are used to transfer logic levels from TTL logic to RS-232C logic.
  • For RS-232C the voltage level +3V to +15V is defined as logic 0 and voltage level from -3V to -15V is defined as logic 1.
  • The line driver, MC 1488, converts logic 1 of TIL to approximately -9V and logic a of TIL to  approximately +9V. These levels at the receiving end are again converted by the line receiver, MC1489, into TTL compatible logic.

 


     

    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

     
     
    FLOWCHART

     

     

     

    INTERFACING DIAGRAM
     

     

    1. Receive message using 8251

    Statement: Write a assembly program to receive 25 bytes from an CRT terminal to 8085 for the following requirements.

           i) Baud rate x 16

           ii) Stop bits 2
     

    Note: Reading of status word is necessary for checking the status of RxD line of 8085 that whether receiver is ready to give data or not.
     
    Source program:

           LXI H, 2300 H                : Initialize memory pointer
           MVI C, FFH                        : Initialize counter to accept 25 characters
           MVI A, 00H
           OUT FFH
           OUT FFH                        : Dummy mode word
           OUT FFH
           MVI A, 40H                        : Reset command word
           OUT FFH                        : Reset 8251 A
           MVI A, CAH                        : Mode word initialization
           OUT FFH
           MVI A, 14 H                        : Command word initialization
           OUT FFH
    CHECK: IN FFH
           ANI 02 H                        : Check RxRDY
           JZ CHECK                        : Is RxRDY ? If not, check again
           IN FEH                        : Get the character
           MOV M, A                        : save the character
           INX H                                : Increment memory pointer
           DCR C                                : Decrement memory pointer
           OUT FEH                        : Send character to the transmitter
           JNZ CHECK                        : If not zero, accept next character
           HLT                                : Stop program execution 

     

    FLOWCHART


     


     

     

     




    Labels: , ,


    Comments:
    where will be the final output?
     
    Post a Comment

    Subscribe to Post Comments [Atom]





    << Home

    This page is powered by Blogger. Isn't yours?

    Subscribe to Posts [Atom]