Display a number, on a single 7 segment LED display

  • Thread starter Thread starter MirrorM
  • Start date Start date
  • Tags Tags
    Led
AI Thread Summary
The discussion focuses on developing a program for the Motorola MC68HC11 microcontroller to display a 10-digit student number on a 7-segment LED display, with each digit shown for 1 second and off for 0.5 seconds. Participants highlight issues with displaying the full student number, as the code only shows the first two digits. The program involves initializing peripheral registers and using a loop to access each digit of the student number, applying corresponding hex patterns for display. A sample solution is provided, demonstrating the necessary code structure and logic to achieve the desired functionality. The thread emphasizes the importance of correctly looping through the digits and using the hex pattern data for accurate display.
MirrorM
Messages
10
Reaction score
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
Here is a sample solution:org $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
 


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
 
I multiplied the values first without the error limit. Got 19.38. rounded it off to 2 significant figures since the given data has 2 significant figures. So = 19. For error I used the above formula. It comes out about 1.48. Now my question is. Should I write the answer as 19±1.5 (rounding 1.48 to 2 significant figures) OR should I write it as 19±1. So in short, should the error have same number of significant figures as the mean value or should it have the same number of decimal places as...
Thread 'A cylinder connected to a hanging mass'
Let's declare that for the cylinder, mass = M = 10 kg Radius = R = 4 m For the wall and the floor, Friction coeff = ##\mu## = 0.5 For the hanging mass, mass = m = 11 kg First, we divide the force according to their respective plane (x and y thing, correct me if I'm wrong) and according to which, cylinder or the hanging mass, they're working on. Force on the hanging mass $$mg - T = ma$$ Force(Cylinder) on y $$N_f + f_w - Mg = 0$$ Force(Cylinder) on x $$T + f_f - N_w = Ma$$ There's also...

Similar threads

Back
Top