The Seven Segment Display

Thread Starter

zhhgw

Joined Jan 11, 2008
4
Hi, I'm new here, i'm having difficulty completing a program on my own. I was given a task to complet 3 programs. I've completed the first 2 but having problems with the last one. Can anybody help me out here? The description of my tasks are below:

Hardware Configuration

The hardware configuration of the 68000 applications boards in the laboratory are as shown in Figure 1. Data to all four seven segment displays is supplied via PortB. A display is activated by outputting a logic 1 on the corresponding Port C control line e.g. outputting a logic 1 will turn on the LSD (Least Significant Digit) display.

Experiment

1) Develop a 68000 assembly language program to produce a count down sequence on the LSD seven segment display after switch connected to PC4 has been asserted.

2) Develop a program that will display the hexadecimal equivalent on the LSD seven segment display of any binary input from PortC bits PC4 to PC7.
(Hint: Use MOVE. B (A0,D0),D1 - Move the byte value from the memory location pointed to by A0 + D0 into D1 where D0 is the four bit value read from the switches).

3) Complete a program that will read any byte value from PortC and display the corresponding hexadecimal values on two seven segment displays. It will be necessary to time multiplex the displays so that the correct value is displayed on the right display at the right time.

Like i mentioned earlier, i've completed task 1 and 2 but i'm stuck with task 3. The circuit diagram of the 7-seg is attached below as well as the program for task 2. My lecturer told me that tasks 2 and 3 are similar but no matter how i tried, i still can't make it work. So if there's a kind soul out there, please help me out I'll be so grateful to u The attachments are below. Thanks.

Hong
Rich (BB code):
Task 2 program:
 
PBDDR EQU $A00007 ; DATA DIRECTION REGISTER (TO CONFIGURE I/O)
PCDDR EQU $A00009 ;
PBDR EQU $A00013 ; ADDRESS OF PORTS AS SHOWN IN DIAGRAM
PCDR EQU $A00019 ;
 
ORG $400400
 
MOVE.B #$FF,PBDDR ; SET PORT B AS O/P
MOVE.B #$0F,PCDDR ; SET PORT C 0-3 0/P, 4-7 I/P
MOVE.B #$01,PCDR ; ENABLE LSD OF 7-SEG DISPLAY
 
BEGIN LEA DATA,A0 ; DEFINE DATA ADD
CLR.B D0 ; RESET D0
CLR.B D1 ; RESET D1
MOVE.B PCDR,D0 ; GRAB 4 BIT DATA INPUT FR ABITEC
ASR.B #4,D0 ; SHIFT 4 BITS TO THE RIGHT AND.B #$0F,D0 ; MAKE LEFT 4 BITS TO BE 0
 
CHECK SUB.B #$00,D0 ; CHECK I/P NO.
BEQ DISPLAY
 
INCR ADD.L #$01,D1 ; INCREASE DATA ADD BY $1
SUB.B #$01,D0 ; SUB I/P NO.
BNE INCR
 
DISPLAY ADDA.L D1,A0 ; ADDING DATA ADD
MOVE.B (A0),D2 ; LOAD THE DATA
MOVE.B D2,PBDR ; DISPLAY DATA
BRA BEGIN ; RESTART
 
DATA DC.B $3F,$06,$5B,$4F,$66,$6D,$7D,$07
DC.B $7F,$6F,$77,$7C,$39,$5E,$79,$71
 
END
The task 3 flowchart

__________________
H.Zhang
 

hgmjr

Joined Jan 28, 2005
9,027
We ask that you avoid multiple identical posting. I have closed your earlier post that was similar to this one.

You may want to take advantage of the CODE tags to make your code more readable.

If you need assistance in using the CODE tag feature I will be happy to help.

hgmjr

PS: It appears that you intended to include either an attached Figure 1 or a link to said figure. However, the attachment or link seems to be absent. You may wnat to edit your post to correct this.
 

scubasteve_911

Joined Dec 27, 2007
1,203
A kind soul would understand that you need to gain experience by struggling through code like that. Or, at the very least, you should attempt creating the code and ask us to make corrections.

I had to do tedious 8051 and x86 coding back in college. I remember everyone struggling to get it done, but we learned a lot in the end. Programming has become an essential skill for an electrical engineer these days, I suggest you embrace it and get excited about it.

Steve
 

RiJoRI

Joined Aug 15, 2007
536
3) Complete a program that will read any byte value from PortC and display the corresponding hexadecimal values on two seven segment displays. It will be necessary to time multiplex the displays so that the correct value is displayed on the right display at the right time.

Q1) How is the byte coming into Port C? As an 8-bit value, or as two nibbles?
Q1a) If it's as a byte, how do you keep the data from affecting the display?
Q2) How do you know the Port C data is valid?

Assuming you are getting two valid nibbles, you will need to

1) Read PortC and isolate the data portion
2) Convert the data to the 7-segment code
3) Write the data to the proper LCD (does the data come MSN-first, or LSN-first)
4) Repeat 1-3 for the next nibble
5) Goto 1

Remember, when faced by a problem, break it down into steps until you get steps that are small enough that you say, "Hey! I can do that!"

--Rich
 

hgmjr

Joined Jan 28, 2005
9,027
Greetings zhhgw,

I went ahead and edited you post to add the CODE tags that I referred to earlier.

No problem with the duplicate post. Many first poster do not realize that one post is sufficient.

I see that you're beginning to receive replies to your question. Hopefully someone can provide you with a solution to your code question.

Good Luck,
hgmjr
 

SgtWookie

Joined Jul 17, 2007
22,230
I'm no stranger to Assembler, but I'm not versed in this particular implementation.

However, I've taken the liberty to reformat your code to how I believe it looked before posting it without the CODE brackets completely fouled it up:
Rich (BB code):
         ;Task 2 program:
 
PBDDR    EQU       $A00007    ; DATA DIRECTION REGISTER (TO CONFIGURE I/O)
PCDDR    EQU       $A00009    ;
PBDR     EQU       $A00013    ; ADDRESS OF PORTS AS SHOWN IN DIAGRAM
PCDR     EQU       $A00019    ;
 
         ORG       $400400
 
         MOVE.B    #$FF,PBDDR ; SET PORT B AS O/P
         MOVE.B    #$0F,PCDDR ; SET PORT C 0-3 0/P, 4-7 I/P
         MOVE.B    #$01,PCDR  ; ENABLE LSD OF 7-SEG DISPLAY
 
BEGIN    LEA       DATA,A0    ; DEFINE DATA ADD
         CLR.B     D0         ; RESET D0
         CLR.B     D1         ; RESET D1
         MOVE.B    PCDR,D0    ; GRAB 4 BIT DATA INPUT FR ABITEC
         ASR.B     #4,D0      ; SHIFT 4 BITS TO THE RIGHT AND.B #$0F,D0 ; MAKE LEFT 4 BITS TO BE 0
 
CHECK    SUB.B     #$00,D0    ; CHECK I/P NO.
         BEQ       DISPLAY
 
INCR     ADD.L     #$01,D1    ; INCREASE DATA ADD BY $1
         SUB.B     #$01,D0    ; SUB I/P NO.
         BNE       INCR
 
DISPLAY  ADDA.L    D1,A0      ; ADDING DATA ADD
         MOVE.B    (A0),D2    ; LOAD THE DATA
         MOVE.B    D2,PBDR    ; DISPLAY DATA
         BRA       BEGIN      ; RESTART
 
DATA     DC.B      $3F,$06,$5B,$4F,$66,$6D,$7D,$07
         DC.B      $7F,$6F,$77,$7C,$39,$5E,$79,$71
 
         END
 

hgmjr

Joined Jan 28, 2005
9,027
zhhgw,

Did you end up posting the schematic diagram or did I miss it?

hgmjr

PS: Nice job sgtwookie. Now that's cool looking code.
 
Top