Continue to Site

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.

  • 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.

how show the accumulator result in Decimal with seven segment.

Status
Not open for further replies.

ikelectro

Member
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:
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
 

Attachments

  • digit.png
    digit.png
    5 KB · Views: 341
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:
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:
;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
 
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..
 
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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top