EASy68K  
It is currently Tue Dec 11, 2018 10:49 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: 7 segment displays
PostPosted: Wed Jun 22, 2011 11:50 am 
Offline

Joined: Sun Jun 19, 2011 1:36 am
Posts: 7
Location: Midwest
How would you write a program to read a decimal number from the keyboard and then display the number on the 7 segment display array? For this question it can be a two digit number but I later need to come up with a 7 or 8 digit number. I know how to read numbers off the keyboard using the "tasks" but no clue how to put said number onto the 7 segment display. :oops:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 22, 2011 2:59 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1087
From clockDigital in the EASy68K examples folder. The comments in the segment7 subroutine explain how to call it.

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

   ds.w  0            force word boundary

*----------------------------------------------------------
* Display a digit on the 7-segment display
* Pre:  D3.B contains 1 digit to display
*       A2 points to 7-segment LED to use
* Post: A2 points to next 7-segment LED

segment7:
   movem.l   d3/a0,-(a7)      save registers
   lea   digits,a0         bit pattern table
   and.l   #$00ff,d3
   move.b   (a0,d3),(a2)   display digit
   adda.l   #2,a2
   movem.l   (a7)+,d3/a0      restore registers
   rts


Note! The segments in the 7-segment display are mapped to every other address in memory. It was fairly common in 68000 computers to have hardware mapped in this manner. The MOVEP instruction is useful when working with this type of peripheral because it accesses every second memory address.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject: further clarification
PostPosted: Wed Jun 22, 2011 3:45 pm 
Offline

Joined: Sun Jun 19, 2011 1:36 am
Posts: 7
Location: Midwest
That code that was listed will not actually display a number typed from the keyboard right? That is only code for how display decimals on the 7 seg display right?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 22, 2011 6:49 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
It displays a single digit, and presupposes you have the address of the LED panel set up.

http://www.easy68k.com/EASy68Kforum/viewtopic.php?t=985

Do you need to read the number a digit at a time? If so use the TRAPs to get characters and process them, if not there is another TRAP to get a decimal number of input.

We're generally loathed to answer homework questions here, dig around a little in the forum and the code examples.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 22, 2011 7:24 pm 
Offline

Joined: Sun Jun 19, 2011 1:36 am
Posts: 7
Location: Midwest
From what I was told it would seem that I need to write it to where as I type it on the keyboard it will show up in the 7-seg display.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 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:  
Powered by phpBB® Forum Software © phpBB Group