Display a number, on a single 7 segment LED display

  • Thread starter MirrorM
  • Start date
  • Tags
    Led
In summary: No operation dex ;Decrement X bne delay1 ;If X is not 0, loop back to "delay1" rts ;Return from the subroutinedelay_off: ldx #$FF ;Initialize X register to $FF delay2: nop ;No operation dex ;Decrement X nop ;No operation nop ;No operation nop ;No operation bne delay2 ;If X is not 0, loop back to "delay2" rts ;Return from the subroutinedone: stop ;Stop the programIn summary, the program is for the Motorola MC68HC11 using the THRSim11 simulator
  • #1
MirrorM
10
0
Can someone please help with the following question. Thanks

Develop a program for the Motorola MC68HC11 using the THRSim11 simulator software. The program is to display a number 10 digits long, one digit at a time, on a single 7 segment LED display. Each digit will be ON for 1 second and OFF for 0.5 Seconds. Once all digits have been displayed the program will stop and the display will be OFF.

The program will make use of all CPU internal registers, and will include subroutines for initializing the peripheral registers and the time delays.

Use the following table of information to commence the program.

LABEL MNEMONIC OPERAND COMMENT
prb equ $1004 Perpheral Port B
ddrb equ $1006 Data direction register B
prc equ $1003 Peripheral port C
ddrc equ $1007 Data direction register C

org $0000
hexpat fcb $3f,$06 Hex bit patterns for
fcb $5b,$4f displaying digits 0 to 9
fcb $66,$6d
fcb $7d,$07
fcb $7f,$6f
number fcc '0010049631' Student number with EOD marker

org $00a0
start

The Problem I have is I can't get it to display the student number, I can only get it to display the 1st 2 hexpat numbers, I believe I have to get it to display the student number using the hexpat data. Would someone please show me how this is done, I've spent hours and hours on this without any luck. Thanks.
 
Physics news on Phys.org
  • #2
Here is a sample solution:eek:rg $0000hexpat fcb $3f,$06 fcb $5b,$4f fcb $66,$6dfcb $7d,$07 fcb $7f,$6fnumber fcc '0010049631' Student number with EOD markerorg $00a0 ;Start program at address 00A0start: ldaa #$00 ;Initialize accumulator A to 0 staa prb ;Store value in port B ldaa #$FF ;Initialize accumulator A to $FF staa ddrb ;Store value in DDRB (data direction register) ldaa #$00 ;Initialize accumulator A to 0 staa prc ;Store value in port C ldaa #$FF ;Initialize accumulator A to $FF staa ddrc ;Store value in DDRC (data direction register)loop: ldx #$00 ;Initialize index register X to 0 ldy #$00 ;Initialize index register Y to 0 jsr display_digit ;Call the subroutine for displaying a digit ldx number,y ;Load the student number from memory into X inc y ;Increment Y by 1 to move to the next digit cpx #$00 ;Compare X to 0 bne loop ;If X is not equal to 0, loop back to "loop" jmp done ;Otherwise, jump to "done"display_digit: ldaa hexpat,x ;Load the hex pattern for the current digit from memory into A staa prb ;Store the value in port B jsr delay_on ;Call the delay subroutine clr prb ;Clear port B jsr delay_off ;Call the delay subroutine rts ;Return from the subroutinedelay_on: ldx #$FF ;Initialize X register to $FF
 
  • #3


First, it's important to understand what the code is trying to accomplish. The program is using the Motorola MC68HC11 microcontroller and the THRSim11 simulator software to display a 10-digit number on a single 7-segment LED display. The number will be displayed one digit at a time, with each digit being on for 1 second and off for 0.5 seconds. Once all digits have been displayed, the program will stop and the display will turn off.

To begin, the code sets up the necessary registers for the peripheral ports B and C. These are used to control the display and its data direction. Then, the code defines a table of hex bit patterns for each digit from 0 to 9. These patterns will be used to display the corresponding digit on the LED display.

Next, the code defines the student number using the FCC (form constant character) directive, with an end-of-data marker at the end. This number will be displayed on the LED display.

The start of the code is then defined at memory address $00a0. This is where the program will begin execution.

To display the student number, the code needs to loop through each digit and display it using the corresponding hex bit pattern. This can be done by using a loop and accessing the student number one character at a time.

Here is an example of how this could be done:

org $00a0
start lda #10 ; Load the number of digits to be displayed
loop ldb #0 ; Load the index for the hexpat table
ldx #number ; Load the address of the student number
ldaa 0,x ; Load the first character of the student number
anda #$0F ; Mask the lower nibble
sta prb ; Send the digit to the display
ldab 0,x ; Load the first character again
anda #$F0 ; Mask the upper nibble
lsra ; Shift the upper nibble to the lower nibble
lsra ; Shift again to get the correct index for the hexpat table
ldaa hexpat,x ; Load the corresponding hex bit pattern
sta prc ; Send the pattern to the display
ldx #hexpat+1 ; Increment the index for the hexpat table
ldaa 0,x ; Load the next character of the student number
anda #$0F ; Mask the lower nibble
sta prb ; Send the digit to
 

1. How does a 7 segment LED display work?

A 7 segment LED display is a type of electronic display device that is used for displaying numbers and sometimes letters or symbols. It consists of seven LED segments (hence the name) that are arranged in a specific pattern to form the numbers 0-9. Each segment is controlled by a separate input, allowing the display to show different combinations of segments to form different numbers.

2. What is the purpose of using a 7 segment LED display?

A 7 segment LED display is commonly used in electronic devices such as digital clocks, calculators, and digital meters. It provides a simple and cost-effective way to display numerical information without the need for complex circuitry or multiple displays.

3. How do you wire a 7 segment LED display?

The exact wiring of a 7 segment LED display will vary depending on the specific model and circuit design. Generally, each segment is connected to a specific pin on the display, and the common cathode or anode is connected to a power source. It is important to consult the manufacturer's datasheet for the specific wiring instructions.

4. Can a 7 segment LED display show decimal points?

Yes, some 7 segment LED displays have an additional segment for displaying decimal points. This segment is typically controlled by a separate input and can be used to display numbers with decimal values.

5. Can multiple 7 segment LED displays be connected together?

Yes, multiple 7 segment LED displays can be connected together to form larger displays. This can be done by connecting the corresponding pins of each display together. For example, the first segment of each display can be connected to form a larger number. Again, it is important to refer to the datasheet for specific wiring instructions.

Similar threads

Replies
6
Views
12K
  • Electrical Engineering
Replies
12
Views
6K
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
13K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
6K
Back
Top