1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

how show the accumulator result in Decimal with seven segment.

Discussion in '8051/8951' started by ikelectro, Oct 22, 2014.

  1. ikelectro

    ikelectro Member

    Joined:
    Aug 25, 2012
    Messages:
    388
    Likes:
    4
    Location:
    Kolkata, Proud to be an Indian.
    Here is simple asm code (for 8051) I write and I want to show the binary result of the ACC in decimal with 7 segment displays. how to do that?

    Code (text):
    ORG 0H
    ASGN:    MOV P1,#255  
            CLR A
            SETB P2.0
    START:    JNB P2.1,WORK
            NOP
            NOP
            JMP START
    WORK:    INC A
            JMP START
            END    
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK

    Attached Files:

  3. ikelectro

    ikelectro Member

    Joined:
    Aug 25, 2012
    Messages:
    388
    Likes:
    4
    Location:
    Kolkata, Proud to be an Indian.
    yes, but acc can normaly show upto 255. if I want to show 1 to 255 (acc results), then I have to put too many times equ instruction.
    And also the concept of lookup table is not familiar to me!
     
    Last edited: Oct 23, 2014
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. ikelectro

    ikelectro Member

    Joined:
    Aug 25, 2012
    Messages:
    388
    Likes:
    4
    Location:
    Kolkata, Proud to be an Indian.

    Actually my main purpose is that: Suppose port P1 is my input of 8bit data which is of course binary. and I want to show the data at port P2 in seven segment. That means i have to add three segment. I know how to interface three segment with 8051 but don't know how to make them decimal corresponding to my input...

    this my asm code to interface 7 segment
    Code (text):
    ;FOR 8051 7SEGMENT DISPLAY TETSING
    ORG 0H
    ZERO EQU 64      ; to show 0 to port 1
    ONE EQU    249         ; to show 1
    TWO EQU 36       ; to show 2
    THREE EQU 48    ; to show 3
    FOUR EQU 25         ; to show 4
    FIVE EQU 18     ; to show 5
    SIX EQU 2       ; to show 6
    SEVEN EQU 248    ; to show 7
    EIGHT EQU 0        ; to show 8
    NINE EQU 16     ; to show 9

    ASSIGN:
    MOV P1,#255
    MOV P2,#255
    LCALL DLY
    START:
    MOV P2, #NINE
    MOV P1,#01
    LCALL DLY
    MOV P1,#02
    MOV p2,#SIX
    LCALL DLY
    MOV P1,#04
    MOV P2,#FIVE
    LCALL DLY
    MOV P1,#08
    MOV P2,#SEVEN
    LCALL DLY
    JMP START


    DLY:
    MOV R0,#255
    DLY1:
    MOV R1,#12
    DLY2:
    DJNZ R1,$
    DJNZ R0,DLY1
    RET


     
     
  6. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    You do know you can buy decoder IC's ... The seven segment is connected to the chip and when the binary data is placed on the port the decoder write to the 7 seg display.... All you need to do is split the ACC result into BCD..
     
  7. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,970
    Likes:
    1,099
    Pseudocode:
    start with x between 0 and 255 decimal, Fix can be an integer divide.

    D100=fix(x/100) ; x = x-x*100
    D10 = fix (x/10); x x x- x*10
    D1 = x

    Display D100; D10 and D1

    If you want implement leading digit blanking. So 001 becomes 1.
     

Share This Page