interfacing 7-segment display

Thread Starter

dreemoo

Joined Nov 21, 2012
4
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
Rich (BB code):
_______________

PORTA EQU 0FFF9H
PORTB EQU 0FFFBH
CNT   EQU 0FFFFH

CODE      SEGMENT
          ASSUME   CS:CODE, DS:CODE

      ORG 0


START:      MOV DX, CNT      ; this part for sending the control word
                  MOV AL, 80H
                  OUT DX, AL


    
J1:    MOV BL,16
        MOV SI, OFFSET FONT
       
       MOV DX, PORTB     ; turn ON the FND
       MOV AL, 11H
       OUT DX, AL


J2:   MOV AL, [SI]
       MOV DX, PORTA
       OUT DX, AL
      

     MOV CX, 0FFFFH
     LOOP $

    INC SI
    DEC BL
    JNZ  J2
  
     

            ;    PGFEDCBA
FONT    DB   11000000B    ;HEXA0
           DB   11111001B    ;HEXA1
           DB   10100100B    ;HEXA2
       DB   10110000B    ;HEXA3
        DB   10011001B    ;HEXA4
       DB   10010010B    ;HEXA5
        DB   10000010B    ;HEXA6
        DB   11011000B    ;HEXA7
        DB   10000000B    ;HEXA8
       DB   10010000B    ;HEXA9
        DB   10001000B    ;HEXA A
       DB   10000011B    ;HEXA B
        DB   11000110B    ;HEXA C
        DB   10100001B    ;HEXA D
       DB   10000110B    ;HEXA E
        DB   10001110B    ;HEXA F
 

CODE  ENDS
END START
_______________________
PLEASE help me


dremo,
 
Last edited by a moderator:

MrChips

Joined Oct 2, 2009
35,168
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.
 

Thread Starter

dreemoo

Joined Nov 21, 2012
4
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.
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
 

MrChips

Joined Oct 2, 2009
35,168
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.
 

t06afre

Joined May 11, 2009
5,934
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.
 

Thread Starter

dreemoo

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

Rich (BB code):
PORTA EQU 0FFF9H
PORTB EQU 0FFFBH
CNT   EQU 0FFFFH

CODE      SEGMENT
          ASSUME   CS:CODE, DS:CODE

      ORG 00


START:            MOV DX, CNT      
                  MOV AL, 80H
                  OUT DX, AL


    
J1:     MOV CL, 100
        MOV SI, OFFSET FONT
        MOV CH, 0
        
       


  J2:    MOV AL, CH
          
         MOV BL, 10
         DIV BL    ; AL= AL/10 AH= AL%10
         PUSH AX
         MOV AH, 0       
         MOV SI, AX
         MOV AL, 01H
         MOV DX, PORTB
         OUT DX, AL
         MOV AL, [SI]
         MOV DX, PORTA
         OUT DX, AL     ; FIRST DIGIT
         CALL DELAY
         
         MOV AL, 02H
         MOV DX, PORTB
         OUT DX, AL
         
         POP AX
         MOV AL, 0
         MOV SI, AX
         MOV AL, [SI]
         MOV DX, PORTA
         OUT DX, AL     ; SECOND DIGIT
         CALL DELAY
       
    
         INC CH

         DEC CL
         JNZ  J2
  

DELAY :    MOV CX, 0FFFFH
           LOOP $
     

            ;    PGFEDCBA
FONT       DB   11000000B    ;HEXA0
           DB   11111001B    ;HEXA1
           DB   10100100B    ;HEXA2
           DB   10110000B    ;HEXA3
           DB   10011001B    ;HEXA4
           DB   10010010B    ;HEXA5
           DB   10000010B    ;HEXA6
           DB   11011000B    ;HEXA7
           DB   10000000B    ;HEXA8
           DB   10010000B    ;HEXA9
           DB   10001000B    ;HEXA A
           DB   10000011B    ;HEXA B
           DB   11000110B    ;HEXA C
           DB   10100001B    ;HEXA D
           DB   10000110B    ;HEXA E
           DB   10001110B    ;HEXA F
 

CODE  ENDS
END START

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?
 
Top