Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Develop a program to display a number, on a single 7 segment LED display

  1. Jun 2, 2005 #1

    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 9 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.

    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
  2. jcsd
  3. Jun 3, 2005 #2
    What exactly is your problem?

    -- AI
  4. Jun 3, 2005 #3
    The problem is I cant get the thing to work. I can get it to display the first 2 hexpat numbers and thats it, but I need it to display the student number, using the hexpat data, i think.
  5. Jun 4, 2005 #4
    I havent worked with Motorola chips. I downloaded the THRSim11 software to check it out. It was fun working with the LEDs and the 7 segment displays.

    I noticed that 7 segment display pins 0 to 7 are connected to PB0 to PB7 by default in the simulation software. Now i tried your hex values for 0 to 9 and it didnt work, it means that you have changed the connections. (Or if u havent changed the connections, then the problem you have stated demands you to change connections).

    As for displaying the values is concerned, i will give you an algorithm which you can use. (I am not well aware of the motorola instruction set, so an algorithm is better i suppose)

    Assume that the student number is stored in memory at say NUM
    Also assume that the LED pins are connected to PB0 to PB7
    1. Store hex values of 0 to 9 (i will refer to them as H[0] to H[9]
    2. Load one byte of NUM from memory to a register (say Reg)
    3. Check whether Reg has value 0 or 1 or 2 .... or 9
    4. If Reg has value i then call print procedure with argument H
    5. Give 1 second delay
    6. Reset all pins and wait for 0.5 seconds
    7. If the byte read from NUM was the last byte, stop the process else go to step 2 (which should load the next byte)

    The print procedure
    1. Load H into register say Reg1
    2. calculate Reg1 & 1 and set that value to PB7
    3. Shift Reg1 to right by 1 and go to step 2
    4. Repeat 2 and 3 eight times.

    -- AI
  6. Jun 4, 2005 #5
    Ive been trying to get this to work all night without any luck. I can get it to display the required number of digits but they dont look right, I think the hexpat data is incorrect, is there any way I can check it or maybe my program isnt looking at the hexpat data, but I think it is. please help.
  7. Jun 5, 2005 #6
    Your simulator has gives u a very easy way to play with your LEDs.
    Start the 7 segment display in your simulator and goto View>Pins and choose the appropriate pins to which your 7 segment display is connected.

    A Pins window shows up where u can invert the bits and apply all possible combinations to the pins. You can check whether your hexpat data works or not (it doesnt work for default connections, you need to rewire them if you want to use your hexpat data or you can generate an hexpat data of your own, it isnt very hard)

    -- AI
  8. Apr 24, 2006 #7
    any luck? What program did you end up with?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook