EASy68K  
It is currently Fri May 29, 2020 4:01 am

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: 7 segment display
PostPosted: Thu Mar 10, 2011 2:41 am 
Offline

Joined: Sun Mar 06, 2011 2:54 am
Posts: 15
Location: Malaysia
what is the assembly language instructions to perform the following operations:

-display hex digit "F "on the left hand of 7 segment display
-display hex digit "0 "on the right hand of 7 segment display
-display my birth day(00010001) in decimal on pair of 7 segment


i appreciate any replay and answer to my questions.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2011 12:06 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
Each segment on the 7 segment display is controlled by 1 bit in the byte of data written to the segments address. If the bit is 1 the segment is turned on if the bit is 0 the segment is turned off. The following lists the byte that forms the corresponding digit. The table can be extended to include the formation of many letters. This table is from the example program clockDigital in the EASy68K examples folder.

Code:
*-----------------------------------------------------------
*         A
*       -----
*     F|     |B
*      |  G  |
*       -----
*     E|     |C
*      |  D  |
*       -----   .H
*
* Bit Number  7 6 5 4 3 2 1 0
* Segment     H G F E D C B A

* bit patterns to form digits on readout
digits:
   dc.b  $3F         digit 0
   dc.b  $06         digit 1
   dc.b  $5B         digit 2
   dc.b  $4F         digit 3
   dc.b  $66         digit 4
   dc.b  $6D         digit 5
   dc.b  $7D         digit 6
   dc.b  $07         digit 7
   dc.b  $7F         digit 8
   dc.b  $6F         digit 9
   dc.b  $00         digit off
   dc.b  $40         dash


There are also examples in the Hardware Interaction section on the Examples page of this site.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject: 7 segment display
PostPosted: Thu Mar 10, 2011 1:30 pm 
Offline

Joined: Sun Mar 06, 2011 2:54 am
Posts: 15
Location: Malaysia
thanks for your kind replay..now remain how i state the instruction that been generated to display one of the bits?

example if i want to display F in left and 0 in the right. i tried it by this way:

for F:

A
* -----
* F| |B
* | G |
* -----
* E| |C
* | D |
* -----

F=1000111=$ 74

so the instruction:

Move.W $74,A02



is this right?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2011 3:39 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
The letter F is formed by turning on segments A,E,F,G
In binary this would be: 01110001 or $71

The instruction to write this digit to the 7 segment display, assuming the display is at address $E00000 (the default) would be.
Code:
    MOVE.B #$71,$E00000

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2011 2:38 pm 
Offline

Joined: Sun Mar 06, 2011 2:54 am
Posts: 15
Location: Malaysia
thanks kelly.

this instruction done for one decimal display on 7 segment.

what about if i want to display like 2 decimals in pair of 7 segment

example : i want to display F in left side and 0 in the right side on pair of 7 segment. how the instruction will be?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2011 5:29 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
Each digit of the 7-segment display is mapped to an even address. If the 7-segment display is at address $E00000 (default) then the left digit is at address $E00000, the 2nd digit is at address $E00002, the 3rd digit is at address $E00004, etc.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2011 11:10 pm 
Offline

Joined: Sun Mar 06, 2011 2:54 am
Posts: 15
Location: Malaysia
how about if i want to repeat display two digits continue?

are they under same address every time display?

like if i want to display 1&7 on and off


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 12, 2011 12:21 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
The address of the digits will not change unless you change.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 12, 2011 2:22 am 
Offline

Joined: Sun Mar 06, 2011 2:54 am
Posts: 15
Location: Malaysia
assume my instruction code:

MOVE.B #$71, $E00000 ;7-segment display F on address location E00000
MOVE.B #$3F, $E00002 ;7-segment display 0 on address location E00002

what instruction code to re-loop continuously for both commands?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 12, 2011 3:46 am 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
salim wrote:
what instruction code to re-loop continuously for both commands?

Code:
again:
..
  BRA  again

32-bit Hex Counter Example
Code:
* 32-bit counter demo

   ORG   $1000

START
   move.b   #32,d0         trap task to get address of hardware
   move.b   #1,d1
   trap   #15         get address of 7-segment display
   move.l   d1,a4         A4 = Address of 7-segment display

   clr.l   d0         D0 = 0

loop
   bsr   out7

   addq.l   #1,d0         D0++
   bra   loop

*-----------------------------------------------------------
*         A
*       -----
*     F|     |B
*      |  G  |
*       -----
*     E|     |C
*      |  D  |
*       -----   .H
*
* Bit Number  7 6 5 4 3 2 1 0
* Segment     H G F E D C B A

* bit patterns to form digits on readout
digits:
   dc.b  $3F         digit 0
   dc.b  $06         digit 1
   dc.b  $5B         digit 2
   dc.b  $4F         digit 3
   dc.b  $66         digit 4
   dc.b  $6D         digit 5
   dc.b  $7D         digit 6
   dc.b  $07         digit 7
   dc.b  $7F         digit 8
   dc.b  $6F         digit 9
   dc.b  $77         digit A
   dc.b  $7C         digit B
   dc.b  $39         digit C
   dc.b  $5E         digit D
   dc.b  $79         digit E
   dc.b  $71         digit F

   ds.w  0            force word boundary

*----------------------------------------------------------
* Display 8 hex digits on the 7-segment display
* Pre:  D0 contains number to display
*       A4 points to 7-segment LED to use
* Post:

out7:
   movem.l   d2-d3/a0-a1,-(a7)   save registers

   lea   digits,a0      bit pattern table
   move.l   a4,a1         A1 = 7 segment base

   move.w   #8,d2         count = #digits
nxtdig:
   rol.l   #4,d0
   move.l   d0,d3
   and.l   #$0f,d3         mask digit
   move.b   (a0,d3),(a1)      display digit
   adda.l   #2,a1         next 7 segment element
   subq.w   #1,d2         count--
   bne   nxtdig         while(count)

   movem.l   (a7)+,d2-d3/a0-a1   restore registers
   rts

   END   START


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group