Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

Quirk with my clocks

I'm building a Binary Game for my final project in Digital Logic and Design and a small portion of this game I'm building uses a countdown timer to show how much time you have left in your round.

I hooked up a clock to my output and got it running, counting down 1 second at a time.

Then I hooked up a second clock (same clock but I changed the clock divider by a factor of 10) to my other output and was wanting to have it countdown in 10 second intervals. And it does countdown in 10 second intervals the issue is that it counts down at the wrong time. The 10 second countdown is triggered on the 5 sec of the 1 sec. clock countdown. So I get 99.98.98.97.96.85.84.83.82.81.80.89.88.87.86.75.74.73.72.71.70.79....and so on.....

Any quick fixes? Or has anyone had this issue before? I'm a complete newbie so talk slow and use small words :-P

13 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    In that case all you need is to make sure your divided clocks are in phase. But to avoid the hassle I will run counter1sec on its clock starting from say 1000 at reset release. Then I will run counter10sec starting from say 100 after reset release on same clock but use the other 1/10 clock as clockenable to count down.

    Thus at start after reset release it should align like this:

    1000 999 998 997 996 995 994 993 992 991 990 ...

    100 100 100 100 100 100 100 100 100 100 99 ...

    and don't forget to keep clock enable under reset till release.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Just using 1 clock going into 2 different clock dividers with different values

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    you need to align the two countings such that when counter1sec = 0 ~ 9 it aligns with counter10sec 0 for 10 clocks.

    If you are using two independent clocks you are likely to run into trouble. use fast clock as usual for both counters then use clockenable e.g.

    when counter1sec = 9 then count down the other counter.