# Comparing the frequencies of two slow reference clocks

Discussion in 'Electronic Basics' started by arant, Aug 14, 2006.

1. ### arantGuest

Hi Everyone,

Does anyone have any idea of how to compare two reference clock
frequencies using digital logic only .

The problem is something like this .There are two slow ref clocks Khz
range CLKA (RC oscillator clock) CLKB (crystal oscillator clock) and a
fast sys_clk (pll clock) Mhz range

If freq CLKA > freq CLKB then
op1 = 1
elsif freq CLKA < freq CLKB
op2 = 1
else
op3 = 1
end if

One solution that I can think of is running two parallel counters on
the sys_clk for one period of the CLKA (count a) and CLKB (count b) and
comparing the count values

if count a = count b then
op3 = 1
elsif count a > count b then
op2 = 1 -- freq CLKB > freq CLKA
else -- freq CLKB < freq CLKA
op1 = 1
end if

Is there a better way of doing this instead of using teo parallely
running counters
An optimum solution in terms of area will be highly appreciated

Eagerly awaiting some solutions

2. ### Bob MastaGuest

How about an up-down counter chip like a '193, with CLKA and CLKB
going to the Up and Down inputs, respectively? Then you will either
get a stream of Carry outputs if CLKA is faster, or Borrow if CLKB is
faster.

Best regards,

Bob Masta