Forum Discussion

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

Generating a 0.1 second tick with 50MHz Clock

Hi,

I want to know how to generate a specifically times tick using a clock.. for example I want to create a tick every 0.1 sec using a 50 MHz clock.

The book I am following simply states that to generate this tick create a counter that will count to 5000000.. and once it reaches that value its 0.1 sec.

However it does not explain how such a calculation (assumption) was made.. I want to know how this number is found.. such that if I want to create a 1 sec tick or 0.01 sec tick how do I calculate it?

Thanks a lot.

5 Replies

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

    a simple rule is to invert MHz to get period in microsec then count how many periods in .1 sec:

    1/50 = .02 microsec (clock period)

    .1 sec = .1 * 1000000 microsec

    hence you need .1*1000000/.02 = 5000000 periods
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    One could also say:

    to count 1 second you have a count equal to the clock frequency in Hz, so to count 0.1 second the count will be the clock frequency in Hz times 0.1

    or 50 MHz * 0.1sec = 5M clocks
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    a simple rule is to invert MHz to get period in microsec then count how many periods in .1 sec:

    1/50 = .02 microsec (clock period)

    .1 sec = .1 * 1000000 microsec

    hence you need .1*1000000/.02 = 5000000 periods

    --- Quote End ---

    I understand the first 1/50M = .02 usec since this is the simple Time period formula T = 1/f. However i dont understand the second line, why is .1 multiplied with 1M?

    thanks

    --- Quote Start ---

    One could also say:

    to count 1 second you have a count equal to the clock frequency in Hz, so to count 0.1 second the count will be the clock frequency in Hz times 0.1

    or 50 MHz * 0.1sec = 5M clocks

    --- Quote End ---

    thats pretty simple.. so all I have to do is multiply the clock with the amount of time I need? for example for a 2 sec tick its supposed to be 50MHz * 2 sec?

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

    --- Quote Start ---

    thats pretty simple.. so all I have to do is multiply the clock with the amount of time I need? for example for a 2 sec tick its supposed to be 50MHz * 2 sec?

    --- Quote End ---

    Yes you're right, you would require 100 M clock cycles to generate this tick.

    It's rather simple - 50 MHz tells you that clock cycle is repeated 50 M times in one sec. So in 2 seconds you would have 100 M clock cycles, and 0.5 sec would be accomplished in 25 M cycles.

    Remeber that if you start counting as it usually occurs from zero, you have to count from 0 to (count_number - 1).

    This subtracion of 1 is irrelevant with such big numbers as 50 M clock cycles. but keep that in mind when making small counters, dividers, pulse generators etc.

    best regards