It is currently Wed Sep 18, 2019 10:04 am

 All times are UTC

 Page 1 of 1 [ 7 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: 7 segment displayPosted: Sat Mar 15, 2008 5:19 am

Joined: Sat Mar 15, 2008 4:55 am
Posts: 1
I am really a beginner..can anyone show me the simple way to display and 7 segment.give me a full instruction example..the simple one to display 12345678

Top

 Post subject: Posted: Sat Mar 15, 2008 11:32 am

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1102
The Examples folder of EASy68K contains a program named clockDigital.x68. The segment7 subroutine is in that program:
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
movem.l (a7)+,d3/a0     restore registers
rts

Put the number you want to display in register D3, put the address of the seven segment display in register A2 and call segment7.

_________________
Prof. Kelly

Top

 Post subject: Posted: Mon Sep 21, 2009 5:38 pm

Joined: Wed Jul 08, 2009 11:24 pm
Posts: 14
Location: singapore
i triedd using the code to output 1 but it seems im doing something wrong. i cant see the number 1 and then i get the following error:

ORG \$1000
START: ; first instruction of program

move.b #0,d1
trap #15 display hardware window
move.b #1,d1
trap #15 get address of 7-segment display
move.l d1,a4 A4 = Address of 7-segment display
move.b #2,d1
trap #15 get address of LEDs
move.l d1,a3 A3 = Address of LEDs

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

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
movem.l (a7)+,d3/a0 restore registers
rts

move.l a4,a2
move.b #1,d3
bsr segment7

END START ; last line of source

Top

 Post subject: Posted: Tue Sep 22, 2009 11:06 am

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1102
lostin68k wrote:
ORG \$1000
START: ; first instruction of program

move.b #0,d1
trap #15 display hardware window
move.b #1,d1
trap #15 get address of 7-segment display
move.l d1,a4 A4 = Address of 7-segment display
move.b #2,d1
trap #15 get address of LEDs
move.l d1,a3 A3 = Address of LEDs

digits:
dc.b \$3F digit 0
dc.b \$06 digit 1
dc.b \$5B digit 2
dc.b \$4F digit 3

This is a common problem I see with my students. You have data in the middle of your program. The program begins execution at the START label. It will execute instructions until it reaches the digits: label and then it will try to execute the dc.b data as 68000 instructions. Always place data in a seperate area of memory. Take a look at the digital clock example.

_________________
Prof. Kelly

Top

 Post subject: Posted: Tue Sep 22, 2009 11:16 am

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
Oh bother! I was all ready to post this then saw your reply. Meh, I'll post it anyway.

Lostin68k
The problem is you have mixed your code and data together and, as a result, you end up with EASy68K trying to execute the data.

What you need to do is rearrange your code so it looks more like this ..

Code:
ORG \$1000

start

* Your main program goes here then either ..

MOVEQ       #9,d0             * halt simulator
TRAP        #15

* .. or if you want to run continuously ..

BRA         start             * loop forever

* Now should come any subroutines and data

.. and that will at least execute what you intend instead of trying to execute the data statements.

Lee.

Quote:
This is a common problem I see with my students. You have data in the middle of your program.

It probably doesn't help that the quick start guide programs also do this.

Lee.

Top

 Post subject: Posted: Wed Sep 23, 2009 9:45 pm

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1102
lee wrote:
Oh bother! I was all ready to post this then saw your reply. Meh, I'll post it anyway.

Sorry Lee, I appreciate the feedback you provide on this forum. Please keep it up.

Quote:
It probably doesn't help that the quick start guide programs also do this.

See I said it was a common problem. The quick start guide was written by two students. Thanks for pointing that out. I'll correct the code in the guide.

_________________
Prof. Kelly

Top

 Post subject: Posted: Thu Sep 24, 2009 2:04 am

Joined: Wed Jul 08, 2009 11:24 pm
Posts: 14
Location: singapore
thanks!

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 7 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 5 guests

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

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects