interfacing 7-segment display

Discussion in 'Homework Help' started by dreemoo, Nov 22, 2012.

  1. dreemoo

    Thread Starter New Member

    Nov 21, 2012
    4
    0
    Hi everyone

    I did a circuit to interface 7-segment with 8255 PPI ( which is inside the MTS trainer ) .. an I made this assembly program codes to display the number from 0 to F , and it work fine ..

    But now I have to use ( two ) 7-segment displays to show numbers from 00 to 99 ( 00- 01- 02 .... 99 )
    so How can I modify my codes to satisfy this purpose ?!

    here is the circuit for two segments
    https://www.dropbox.com/s/zk61w84s71i3o8z/Photo%2011-22-12%2C%208%2056%2013%20AM.jpg

    this is my code for one segment
    Code ( (Unknown Language)):
    1.  
    2. _______________
    3.  
    4. [COLOR=Green]PORTA EQU 0FFF9H
    5. PORTB EQU 0FFFBH
    6. CNT   EQU 0FFFFH
    7.  
    8. CODE      SEGMENT
    9.           ASSUME   CS:CODE, DS:CODE
    10.  
    11.       ORG 0
    12.  
    13.  
    14. START:      MOV DX, CNT      ; this part for sending the control word
    15.                   MOV AL, 80H
    16.                   OUT DX, AL
    17.  
    18.  
    19.    
    20. J1:    MOV BL,16
    21.         MOV SI, OFFSET FONT
    22.        
    23.        MOV DX, PORTB     ; turn ON the FND
    24.        MOV AL, 11H
    25.        OUT DX, AL
    26.  
    27.  
    28. J2:   MOV AL, [SI]
    29.        MOV DX, PORTA
    30.        OUT DX, AL
    31.      
    32.  
    33.      MOV CX, 0FFFFH
    34.      LOOP $
    35.  
    36.     INC SI
    37.     DEC BL
    38.     JNZ  J2
    39.  
    40.      
    41.  
    42.             ;    PGFEDCBA
    43. FONT    DB   11000000B    ;HEXA0
    44.            DB   11111001B    ;HEXA1
    45.            DB   10100100B    ;HEXA2
    46.        DB   10110000B    ;HEXA3
    47.         DB   10011001B    ;HEXA4
    48.        DB   10010010B    ;HEXA5
    49.         DB   10000010B    ;HEXA6
    50.         DB   11011000B    ;HEXA7
    51.         DB   10000000B    ;HEXA8
    52.        DB   10010000B    ;HEXA9
    53.         DB   10001000B    ;HEXA A
    54.        DB   10000011B    ;HEXA B
    55.         DB   11000110B    ;HEXA C
    56.         DB   10100001B    ;HEXA D
    57.        DB   10000110B    ;HEXA E
    58.         DB   10001110B    ;HEXA F
    59.  
    60.  
    61. CODE  ENDS
    62. END START[/COLOR]
    63. _______________________
    64.  
    PLEASE help me


    dremo,
     
    Last edited by a moderator: Nov 22, 2012
  2. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    You can use another seven output lines.
    Or you can use the same seven outputs plus one or two extra output lines to select
    the digit and muliplex the seven lines.

    Edit: Sorry, I only just saw your circuit. This is correct.
    Now switch back and forth between the two displays.
     
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    This looks like 8086 assembler. Have you looked at the DAA instruction
     
  4. dreemoo

    Thread Starter New Member

    Nov 21, 2012
    4
    0
    uh do you mean after showing the first digit I'll make it off then make the other digit ON ?
    and is it correct if I make the first digit to loop 9 times for each number of the second digit .. so that it will be like this
    00- 01 - 02- 03- 04- 05- 06- 07- 08- 09- 19 .......

    thanks for your reply
     
  5. dreemoo

    Thread Starter New Member

    Nov 21, 2012
    4
    0
    I've just read about it , but how I'm gonna use it here ^^" !
     
  6. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    No.

    First of all, why are you sending 11H to PORTB?

    1) You need to specify if you are using common anode or common cathode displays.
    From your code I can guess you are using common anode.

    2) Suppose you want to display 34.
    Send the seven segment output for 4 to PORTA and send 01H to PORTB.
    Delay for about 10ms.
    Send the seven segment output for 3 to PORTA and send 02H to PORTB,
    Delay for about 10ms.
    Repeat continuously.
     
  7. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    It looks like you use a common anode display. In any way I think you must use transistor to control it on/off. As one output on PORTB. Not will be able to source the current needed for more than one segment
    If you blink a LED with a high enough frequency. The human eye is slow so you do not need that high frequency It will appear as it is on. And that is what you need here. If not you have to use some sort of a data latch. Which also is a OK solution.
     
  8. dreemoo

    Thread Starter New Member

    Nov 21, 2012
    4
    0
    OK guys I followed your instructions and change my codes

    Code ( (Unknown Language)):
    1.  
    2. PORTA EQU 0FFF9H
    3. PORTB EQU 0FFFBH
    4. CNT   EQU 0FFFFH
    5.  
    6. CODE      SEGMENT
    7.           ASSUME   CS:CODE, DS:CODE
    8.  
    9.       ORG 00
    10.  
    11.  
    12. START:            MOV DX, CNT      
    13.                   MOV AL, 80H
    14.                   OUT DX, AL
    15.  
    16.  
    17.    
    18. J1:     MOV CL, 100
    19.         MOV SI, OFFSET FONT
    20.         MOV CH, 0
    21.        
    22.        
    23.  
    24.  
    25.   J2:    MOV AL, CH
    26.          
    27.          MOV BL, 10
    28.          DIV BL    ; AL= AL/10 AH= AL%10
    29.          PUSH AX
    30.          MOV AH, 0      
    31.          MOV SI, AX
    32.          MOV AL, 01H
    33.          MOV DX, PORTB
    34.          OUT DX, AL
    35.          MOV AL, [SI]
    36.          MOV DX, PORTA
    37.          OUT DX, AL     ; FIRST DIGIT
    38.          CALL DELAY
    39.          
    40.          MOV AL, 02H
    41.          MOV DX, PORTB
    42.          OUT DX, AL
    43.          
    44.          POP AX
    45.          MOV AL, 0
    46.          MOV SI, AX
    47.          MOV AL, [SI]
    48.          MOV DX, PORTA
    49.          OUT DX, AL     ; SECOND DIGIT
    50.          CALL DELAY
    51.        
    52.    
    53.          INC CH
    54.  
    55.          DEC CL
    56.          JNZ  J2
    57.  
    58.  
    59. DELAY :    MOV CX, 0FFFFH
    60.            LOOP $
    61.      
    62.  
    63.             ;    PGFEDCBA
    64. FONT       DB   11000000B    ;HEXA0
    65.            DB   11111001B    ;HEXA1
    66.            DB   10100100B    ;HEXA2
    67.            DB   10110000B    ;HEXA3
    68.            DB   10011001B    ;HEXA4
    69.            DB   10010010B    ;HEXA5
    70.            DB   10000010B    ;HEXA6
    71.            DB   11011000B    ;HEXA7
    72.            DB   10000000B    ;HEXA8
    73.            DB   10010000B    ;HEXA9
    74.            DB   10001000B    ;HEXA A
    75.            DB   10000011B    ;HEXA B
    76.            DB   11000110B    ;HEXA C
    77.            DB   10100001B    ;HEXA D
    78.            DB   10000110B    ;HEXA E
    79.            DB   10001110B    ;HEXA F
    80.  
    81.  
    82. CODE  ENDS
    83. END START
    84.  
    85.  

    I don't have the circuit right now , but I've checked the syntax errors and it was OK
    so do you think that it will work with this codes?
     
Loading...