building a microprocessor - time delay

Discussion in 'The Projects Forum' started by dottie, Jul 23, 2011.

  1. dottie

    Thread Starter New Member

    Jul 23, 2011
    2
    0
    Hi,
    a year ago i thought it would be awesome to build myself a microprocessor out of discrete 74HC parts (I had no idea what it would be like). ATM I have a working ALU and memory unit, but I'm kinda stuck at a "SLEEP" instruction. I plan on adding a 8x8 LED array to my microprocessor, so I can play pong or something like that :)

    So I bought 8 SIPO shift registers and connected the LEDs. So to draw a complete "scene" (64 bits) it takes me 8 steps ... But here's the problem: I need to draw the scene, then wait for some time to get user input and then redraw. I figured it would be best to check for input, then sleep for some time and do that over and over, before redrawing the scene.

    I actually need some component, that stays on HIGH (5V) and when I trigger it, it would go LOW (0V) for some time and then back on HIGH again.

    I think the best would be to use some sort of binary counter, but I decided to ask the wiser :)

    Thanks !
     
  2. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    If your procesor has conditional statements, then just make a while loop and count to some number before the program continues.
     
  3. dottie

    Thread Starter New Member

    Jul 23, 2011
    2
    0
    Yeah, that was my first thought, but I only have 8bit addressing, so 255 instrucitons is probably not enought to make 1 sec delay. I mean it is, but it would probably take up all the space left for the program itself.

    PS: take jsem cech :)
     
  4. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    What is your clock frequency?
    For example a triple-nested loop that can make a delay of up to 256^3 ticks should take cca 8-10 instructions.
     
  5. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Here is a loop example in pseudocode, it should take 8 instructions to do the counting:

    Code ( (Unknown Language)):
    1.  
    2. X=200
    3. Y=210
    4. Z=220
    5.  
    6. a:
    7. decrease X
    8. if X!=0 jmp a
    9. X=200
    10.  
    11. decrease Y
    12. if Y!=0 jmp a
    13. Y=210
    14.  
    15. decrease Z
    16. if Z!=0 jmp a
    17.  
    18. this will take 200*210*220=9,240,000 ticks to get here, which should be
    19. more than enough even if your processor runs at 10MHz which I doubt
     
Loading...