Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

16 bit value on 7 segment display

Status
Not open for further replies.

neelam29

Newbie level 4
Joined
Feb 4, 2005
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
58
bruno marcio diogo venancio

hi friends,
i'm having a 16-bit value (4-digit value) in two 8-bit registers, let it be R1 & R2. now i want to dislay the value on 4, 7-segment display, how can i do it. Please help me. I'm using 89c51
Thank you.
 

If this is binary number (16-bit) you have to convert it to 4 digit BCD number in such a way that lower nibble of R1 contains the lowest number (digit), .. , higher nibble of R2 contains the highest number to be displayed (search the net for bin-BCD conversion subroutine)
Once you have BCD (binary coded decimal) in this format ( R1=D2D1 R2 = D4D3) you can display each nibble as a number in the range 0-9 on 4-digit 7-segment display ..
Dou you want to do it dynamically(sequentially)?


Conversion example:
**broken link removed**
 

Thanks. Ya i think i need to display all the 4 digits sequentially, on 4 , 7-segment displays, connected to a common port and having 4 common lines on other port.
secondly, the link you gave was having code in C, but i'm doing coding in Assembly. But the link you gave was having many other codings which would be very helpful for me thanks.
 

OK, you didn't mention assembly or C.
Here is link to assembly:
**broken link removed**
 

Salam,

I have used this code in Big segment counter project.
The input is 16 bit number in R2 and R3, And the output is 5 digits in ASCII stored in RAM from 0x30-0x34


Code:
;
;  +-------------------------------------------------------------------------+
;  | Purpose: Routine to convert a 16bit binary number in ASCII
;  |                                                                         |
;  | INPUT : R2 (Lsb) and R3 (Msb)   ( binary)                               |
;  |                                                                         |
;  | OUPUT : 30h,31h,32h,33h,34h  (internal RAM address)  (ASCII)            |
;  |   msb--^                  ^------lsb                                       |
;  |                                                                         |
;  | Destroy all registers                                                   |
;  |                                                                         |
;  | PROGRAMMER: Bruno Marcio Diogo Venancio ( [email]bruno.marcio@bol.com.br[/email] )     |
;  | BRAZIL 07/19/2002                                                       |
;  |          THIS CODE CAN BE FREELY DISTRIBUTED WITHOUT CHANGES            |
;  +-------------------------------------------------------------------------+
;
; Use example:    
;                      
;START:
;        MOV R2,#low(1234)                                
;        MOV R3,#high(1234)
;        LCALL  BINTOASC
;       
;   in 30h until 34h of internal RAM will be :'0','1',' 2',','3','4' ( ASCII)
;
;
;             The Routine Algorithm
;
;
;                  +-------+
;                  | START |
;                  +---+---+
;                      |         
;                  +-------+
;                  |   N   |        ( N= Number to be coverted)
;                  +-------+
;                      |
;                +-------------+
;                | POUT   <- 0 |    ( POUT = Output address )        
;                +-------------+
;                      |
;                 +--------+
;                 | P <- 0 |      ( P= Table Index )
;                 +--------+
;                      |
;                      |
;     +----------->    | 
;     |           +-------------+ ( R = Register )
;     |           | R <- TAB(P) | ( Fetch a table number indexed by P ) 
;     |           +-------------+
;     |                |
;     |           +----------+
;     |           | C <- '0' |    ( C= counter)
;     |           +----------+    ( counter <- 0 in ASCII)
;     |                |
;     |    +------>    |
;     |    |      +-----------+
;     |    |      | N <-  N-R |   ( subtract the table number with R )
;     |    |      +-----------+                                          
;     |    |           |
;     |    |      N   /  \   Y
;     |    |     +--< N<0? >-----------+
;     |    |     |   \    /            |
;     |    |     |     \/              |
;     |    |     |             +--------------------+
;     |    |  +-------+        | TABOUT (POUT) <- C |
;     |    |  |C<- C+1|        +--------------------+
;     |    |  +-------+                |
;     |    |     |                +----------+
;     |    +-----+                | N <- N+R |
;     |                           +----------+
;     |                                |
;     |                       +------------------+
;     |                       | POUT  <- POUT +1 |
;     |                       +------------------+
;     |                                |
;     |                               /^\
;     |                             /     \
;     |   +----------+         N  /         \ S
;     +---| P <- P+1 |-----------< TAB(P)=1? > ---------+
;         +----------+            \         /           |
;                                   \     /             |
;                                     \ /               |
;                                                    +-----+
;                                                    | END |
;                                                    +-----+
;
;           
 
BINTOASC:

        MOV R0,#30h                 ; R0 = POUT 
        MOV DPTR,#TAB               ; R=TAB(P)

COM1:

        CLR A                       ; P <- 0     
        MOVC A,@A+DPTR              ; R <-  TAB(P)
        MOV R7,A
        INC DPTR
        CLR A
        MOVC A,@A+DPTR
        MOV R6,A

        MOV R4,#'0'                  ; C  <- '0'


SOMA:                                ; N <-  N-R 
      CLR C        ;              
      MOV A,R2     ;              
      SUBB A,R6    ;              
      MOV R2,A     ;              
                                 
      MOV A,R3     ;               
      SUBB A,R7    ;              
      MOV R3,A     ;              
      JC SAIDA     ;    If < 0 goto  SAIDA
      INC R4       ;    If >0 then C <- C +1
      SJMP SOMA    ;    goto SOMA            
SAIDA:
      MOV A,R4                 
      MOV @R0,A              ;TABOUT (POUT) <- C

      MOV A,R2             
      ADD A,R6               ;  N=N+R
      MOV R2,A             
                           
      MOV A,R3             
      ADDC A,R7            
      MOV R3,A             

      INC R0                 ; PSAIDA=PSAIDA +1

      CLR A
      MOVC A,@A+DPTR
      CJNE A,#1,INCREMENTA   ; TAB(P) = 1 ?
      RET                    ; If yes, END

INCREMENTA:                  ; If No, P <- P+1
      INC DPTR
      LJMP COM1              ; goto COM1


TAB:
     DW 10000
     DW 1000
     DW 100
     DW 10
     DW 1


SphinX

Added after 1 minutes:

Salam,

Another code

**broken link removed**

Bye
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top