The Seven Segment Display

Discussion in 'Homework Help' started by zhhgw, Jan 11, 2008.

  1. zhhgw

    Thread Starter New Member

    Jan 11, 2008
    4
    0
    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
    Code ( (Unknown Language)):
    1.  
    2.  
    3. Task 2 program:
    4.  
    5. PBDDR EQU $A00007 ; DATA DIRECTION REGISTER (TO CONFIGURE I/O)
    6. PCDDR EQU $A00009 ;
    7. PBDR EQU $A00013 ; ADDRESS OF PORTS AS SHOWN IN DIAGRAM
    8. PCDR EQU $A00019 ;
    9.  
    10. ORG $400400
    11.  
    12. MOVE.B #$FF,PBDDR ; SET PORT B AS O/P
    13. MOVE.B #$0F,PCDDR ; SET PORT C 0-3 0/P, 4-7 I/P
    14. MOVE.B #$01,PCDR ; ENABLE LSD OF 7-SEG DISPLAY
    15.  
    16. BEGIN LEA DATA,A0 ; DEFINE DATA ADD
    17. CLR.B D0 ; RESET D0
    18. CLR.B D1 ; RESET D1
    19. MOVE.B PCDR,D0 ; GRAB 4 BIT DATA INPUT FR ABITEC
    20. ASR.B #4,D0 ; SHIFT 4 BITS TO THE RIGHT AND.B #$0F,D0 ; MAKE LEFT 4 BITS TO BE 0
    21.  
    22. CHECK SUB.B #$00,D0 ; CHECK I/P NO.
    23. BEQ DISPLAY
    24.  
    25. INCR ADD.L #$01,D1 ; INCREASE DATA ADD BY $1
    26. SUB.B #$01,D0 ; SUB I/P NO.
    27. BNE INCR
    28.  
    29. DISPLAY ADDA.L D1,A0 ; ADDING DATA ADD
    30. MOVE.B (A0),D2 ; LOAD THE DATA
    31. MOVE.B D2,PBDR ; DISPLAY DATA
    32. BRA BEGIN ; RESTART
    33.  
    34. DATA DC.B $3F,$06,$5B,$4F,$66,$6D,$7D,$07
    35. DC.B $7F,$6F,$77,$7C,$39,$5E,$79,$71
    36.  
    37. END
    38.  
    The task 3 flowchart
    [​IMG]
    __________________
    H.Zhang
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    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.
     
  3. zhhgw

    Thread Starter New Member

    Jan 11, 2008
    4
    0
    sorry, i will never do that again
     
  4. scubasteve_911

    Senior Member

    Dec 27, 2007
    1,202
    1
    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
     
  5. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    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
     
  6. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    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
     
  7. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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:
    Code ( (Unknown Language)):
    1.          ;Task 2 program:
    2.  
    3. PBDDR    EQU       $A00007    ; DATA DIRECTION REGISTER (TO CONFIGURE I/O)
    4. PCDDR    EQU       $A00009    ;
    5. PBDR     EQU       $A00013    ; ADDRESS OF PORTS AS SHOWN IN DIAGRAM
    6. PCDR     EQU       $A00019    ;
    7.  
    8.          ORG       $400400
    9.  
    10.          MOVE.B    #$FF,PBDDR ; SET PORT B AS O/P
    11.          MOVE.B    #$0F,PCDDR ; SET PORT C 0-3 0/P, 4-7 I/P
    12.          MOVE.B    #$01,PCDR  ; ENABLE LSD OF 7-SEG DISPLAY
    13.  
    14. BEGIN    LEA       DATA,A0    ; DEFINE DATA ADD
    15.          CLR.B     D0         ; RESET D0
    16.          CLR.B     D1         ; RESET D1
    17.          MOVE.B    PCDR,D0    ; GRAB 4 BIT DATA INPUT FR ABITEC
    18.          ASR.B     #4,D0      ; SHIFT 4 BITS TO THE RIGHT AND.B #$0F,D0 ; MAKE LEFT 4 BITS TO BE 0
    19.  
    20. CHECK    SUB.B     #$00,D0    ; CHECK I/P NO.
    21.          BEQ       DISPLAY
    22.  
    23. INCR     ADD.L     #$01,D1    ; INCREASE DATA ADD BY $1
    24.          SUB.B     #$01,D0    ; SUB I/P NO.
    25.          BNE       INCR
    26.  
    27. DISPLAY  ADDA.L    D1,A0      ; ADDING DATA ADD
    28.          MOVE.B    (A0),D2    ; LOAD THE DATA
    29.          MOVE.B    D2,PBDR    ; DISPLAY DATA
    30.          BRA       BEGIN      ; RESTART
    31.  
    32. DATA     DC.B      $3F,$06,$5B,$4F,$66,$6D,$7D,$07
    33.          DC.B      $7F,$6F,$77,$7C,$39,$5E,$79,$71
    34.  
    35.          END
     
  8. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    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.
     
  9. zhhgw

    Thread Starter New Member

    Jan 11, 2008
    4
    0
    thank you !!hgmjr, sgtwwookie and Rich



    Hong
     
Loading...