# Patent

## Title
Non-linear frequency and phase measurement scheme

## Abstract

The present invention relates to a method and apparatus for measuring a frequency or a phase of a measuring signal, wherein the frequency (fg) or the phase (φg) are estimated by approximating the relationship between a collecting clock (c) and a gating clock (g) based on a non-linear step-shaped function. Thereby, the estimation error can be improved with almost negligible complexity increase in signal processing.

## Background
The present invention relates to a method and apparatus for measuring a frequency or a phase of a measuring signal. In particular, the present invention relates to an accurate frequency and phase measurement scheme for synchronizing electronic circuits operated from independent clock oscillators.
Electronic circuits for frequency measurement are used in a wide spectrum of electromechanical and electronic systems, such as for instance revolution controllers in Compact Disc (CD) or hard disc drives or interface circuits for the synchronization of electronic subsystems which are operated from independent clock oscillators.
A typical example for the latter ones are GSM (Global System for Mobile communication) mobile phones with GPS (Global Positioning System) capability. In such systems, a GPS receiver on the ground measures the times of arrival of signals from different satellites in the sky. The times of arrival of the signals along with the exact location of the satellites and the exact times the signals were transmitted from each satellite are used to triangulate the position of the GPS receiver. A standard GPS receiver includes a local oscillator used to receive the GPS signal from the satellites. The acquisition of signals from the GPS satellites is highly sensitive to frequency variations in the local oscillator of the GPS receiver. A number of factors contribute to making the acquisition of the GPS signals difficult. As a result, if the GPS receivers local oscillator frequency is even slightly of the GPS frequency, it may be difficult and time consuming to effectively receive the GPS signals.
In a typical example for a GSM mobile phone with GPS capability up to three independent crystal oscillators (XOs) may be used, wherein a 26 MHz XO and a 32 kHz XO supply the GSM subsystem during active time and idle time, respectively, and a 21 MHz XO supplies the GPS subsystem. The 26 MHz XO is required as a clean frequency for the GSM RF (Radio Frequency) synthesizers in GSM active mode, while the low power 32 kHz XO helps reducing the power consumption in GSM idle mode when most of the GSM system including the 26 MHz XO is powered down. Merely the 32 kHz XO and a counter denoted as the 32 kHz ‘sleep counter’ are active. The sleep counter serves as a timer to power up the GSM system in time before a new paging message sent by the base stations arrives. Due to tolerances and temperature drift of the 32 kHz XO, the GSM mobile phone could easily miss a part of the paging message. This is why GSM mobile phones include a frequency measurement unit which serves for estimating the frequency ration between the 32 kHz XO and the 26 MHz XO. A similar need for frequency measurement arose recently with the development of GPS capable GSM mobile phones. This is because GPS receivers ICs (Integrated Circuits) traditionally use another reference frequency than the standard 26 MHz of GSM and therefore need a dedicated GPS XO.
In both cases, the accuracy requirements lead to measurement periods of several seconds if a conventional frequency measurement unit based on counters is employed. The task of such a frequency measurement unit is to measure the frequency ratio fc/fg of two independent digital clock signals which shall be denoted as the gating clock and the collecting clock, corresponding to respective clock frequencies fg, fc and clock periods Tg=1/fg and Tc=1/fc. Simple conventional frequency measurement circuits comprise two counters, namely the gating counter and the collecting counter which are clocked by the respective clocks. The gating counter in combination with some comparator logic determines the measurement period by enabling the collecting counter for a certain number of gating counter cycles Ng. The number of cycles the collecting counter collects during the measurement period shall be denoted as Nc. Expressing the measurement period in multiples of both Tg and Tc leads to the following equation:

NgTg=NcTc+dTc  (1)

where NgTg is the measurement period in seconds and the unknown term dTc with −1<d<1 takes into account that the measurement period may be not an integer multiple of Tc while the collecting counter can resolve only integer multiples of Tc. Reorganizing the above equation yields the expression





  
    
      
        
          
            f
            c
          
          
            f
            g
          
        
        =
        
          
            
              
                N
                c
              
              
                N
                g
              
            
            ·
            
              (
              
                1
                +
                
                  d
                  
                    N
                    c
                  
                
              
              )
            
          
          =
          
            
              
                N
                c
              
              
                N
                g
              
            
            ·
            
              (
              
                1
                +
                ɛ
              
              )
            
          
        
      
    
    
      
        (
        2
        )
      
    
  




where ε=d/Nc represents the relative measurement error. Assuming a typical GSM/GPS measurement with period NcTc=1s, Tc=1/fc=1/(26 MHz), the worst case relative error for d=1 and Nc=26·106 is ε≅0.04·10−6.

A square wave clock signal can be associated with φ(t), the phase of its Fourier fundamental frequency. φ(t) is a linear ramp which is characterized by the initial phase φ and the frequency f, and it is expressed by:

φ(t)=2πft+φ.  (3)

It is noted that φ(t) is understood to be unwrapped, i.e., not limited to the interval [0,2π[. In the following, the normalized phase is defined as η(t)=φ(t)/(2π) and the current value of a clock counter is {circumflex over (η)}(t) denoted as {circumflex over (η)}(t) Apparently, can be regarded as a quantized version of η(t) which is formally expressed as follows:

{circumflex over (Θ)}(t)=└η(t)┘  (4)

where the function └x┘ represents the closest integer number equal to or less than x such that 0≦x−└x┘<1 applies. The triggering edge of the clock signal shall correspond to the clock phases η(t) mod 1=0. The quantization causes the smooth phase ramp η(t) to become step-shaped. Furthermore, the expression





  
    
      
        
          
            η
            c
          
          ⁡
          
            (
            t
            )
          
        
        =
        
          
            
              f
              c
            
            ⁢
            t
          
          +
          
            
              φ
              c
            
            
              2
              ⁢
              
                
              
              ⁢
              π
            
          
        
      
    
    
      
        (
        5
        )
      
    
  




is denoted as the non-quantized normalized phase of the collecting clock, and

ηg(t)=fgt  (6)

as the non-quantized normalized phase of the gating clock, where ηg(t=0)=0 holds without loss of generality. It is noted that ηg(t) can be considered as normalized time ηg(t)=t/Tg likewise because of fg=1/Tg. Substituting t=ηg/fg into Eq. (5) and dropping the time index for the sake of clarity, the following expression is obtained:





  
    
      
        
          
            η
            c
          
          ⁡
          
            (
            
              
                η
                g
              
              
                f
                g
              
            
            )
          
        
        =
        
          
            
              
                f
                c
              
              
                f
                g
              
            
            ⁢
            
              η
              g
            
          
          +
          
            
              
                φ
                c
              
              
                2
                ⁢
                
                  
                
                ⁢
                π
              
            
            .
          
        
      
    
    
      
        (
        7
        )
      
    
  




In the light of Eq. (7), frequency measurements turn into the problem of estimating the steepness or slope of the phase ramp ηc(ηg/fg), which corresponds to the frequency ratio fc/fg.
In the following, we define ηc[k]=ηc(k/fg), where k is an integer and represents values of the gating clock counter being equal to integer values of the normalized phase ηg.
In the conventional approach, samples {circumflex over (η)}c[k0] and {circumflex over (η)}c[k1] are taken from the collecting counter as an approximation of ηc[k0] and ηc[k1]. Here, k0 and k1 designate the first and the last value of the gating counter spanning the measurement period, and {circumflex over (η)}c[k] designates the value of the collecting counter at the beginning of the k-th gating clock period. However, the respective outcome of the estimation of the frequency ratio depends on the phase relation between the collecting clock and the gating clock. As a consequence the estimate of the desired frequency ratio fc/fg spreads. Thus, estimating the slope of the non-quantized phase ramp ηc[k] of the collecting clock based on observations of its quantized version {circumflex over (η)}c[k] is sub-optimal when it makes use of only two samples from {circumflex over (η)}c[k]
As a solution to the above spreading problem, a multiple phase sampling and regression scheme has been proposed where a total of Ng+1 samples is taken from the collecting counter, given a measurement interval lasting Ng=k1−k0 gating clock cycles. Based on these Ng+1 samples, a regression line is calculated which leads to a better estimate of ηc in terms of slope. For practical reasons, it may be desirable to consider a subset of the Ng+1 samples comprising only M≦Ng+1 collecting counter samples where ηg[m], 0≦m≦M, designate the corresponding gating counter values. Based on this subset the unknown parameters of the regression line, which are the normalized phase offset a0 and slope a1 are then determined based on statistical rules of the regression analysis as known in the art.
In the derivation of the linear regression algorithm, the relationship between the gating clock samples and the collection clock samples is approximated by the curve

{circumflex over (η)}c└ηg[m]┘≅a0+a1ηg[m], 

where the best solutions for the phase offset a0 and the slope a1 are to be found by solving a least square's problem. In reality, however the approximation of the gating and collecting counters relationship by a linear function is in general sub-optimal. Therefore, there is still room for further improvement of frequency estimation.

It is therefore an object of the present invention to provide an improved phase and frequency measurement with higher accuracy.
Accordingly, an accurate frequency and phase measurement is provided, in which the actual non-linearity of the underlying problem is exploited in order to obtain frequency as well as phase measurement accuracies which can exceed by far those of the above known measurement principles. In fact, a significant reduction of the product of measurement error and measurement period can be achieved. Moreover, the same counter values already derived from a linear regression based algorithm can be used, such that no additional hardware is necessary. The underlying simple estimation principle can be implemented on microcontrollers or digital signal processors which are available in most electronic devices, e.g. mobile phones, where a corresponding measurement is to be performed. It may even be easily implemented in dedicated hardware.
As the relationship between the collecting clock and the gating clock is determined based on the non-linear step-shaped function, better estimates can be obtained for the slope and offset values required for estimation.
The estimation means may comprise first counter means for counting the collecting clock and second counter means for counting the gating clock, wherein the estimating means may be arranged to perform the estimation based on account values of the first and the second counter means. As already mentioned, the use of the first and second counter means provides the advantage that counter values already derived from other estimation schemes, such as the linear regression, can be used for the proposed estimation and no additional hardware is necessary.
Preferably, the estimating means may be arranged to perform the estimation by an iterative process. Using the iterative process, the estimation error can be improved by orders of magnitude with almost negligible complexity increase in signal processing. In particular, the estimating means may be arranged to calculate estimates for a minimum value and a maximum value of the frequency ratio between the collecting clock and the gating clock. These estimates may be calculated by using minimum and maximum values of the phase offset between the collecting clock and the gating clock.
Additionally, the estimating means may be arranged to calculate estimates for a minimum value and a maximum value of a phase offset between the collecting clock and the gating clock. These estimates may be calculated by using minimum and maximum values of the frequency ratio between the collecting clock and the gating clock. Minimum and maximum estimates for the slope can thus be determined when having an estimate for the phase offset, and minimum and maximum estimates for phase offset can be determined when having an estimate for the slope. In case of an iterative procedure, accuracy can be improved with each iteration step. The calculation can be carried out for several iteration steps if appropriate prior estimates are available. The estimation can thus be solved recursively in an iterative way.
As a further option, the estimating means may be arranged to average the estimates so as to obtain the frequency or phase. The initial values required for the iterative estimation may be obtained from estimates of another estimation function or from given system parameters. As an example, this other estimation function may be based on a regression. Thereby, coarse or rough estimates for the desired parameters can be used as a starting point of the proposed non-linear estimation scheme.
In view of the fact that the proposed estimation may easily be implemented in connection with processors or processing means in respective electronic devices, it may be implemented as a computer program product, e.g. stored on a record carrier or downloadable from a data network, wherein code means of the computer program product are adapted to control the processor means so as to produce the claimed method steps when loaded into the memory of the respective electronic device controlled by the processor means.



The present invention will now be described based on a preferred embodiment with reference to the accompanying drawings in which:
FIG. 1 shows a schematic block diagram of a mobile phone device according to the preferred embodiment of the present invention;
FIG. 2 shows a schematic diagram showing the basic principle of the proposed measurement approach according to the preferred embodiment;
FIG. 3 shows a schematic flow diagram of a phase and frequency measurement according to the preferred embodiment;
FIG. 4 shows a diagram indicating relative frequency error versus number of samples for the measurement according to the preferred embodiment in comparison with conventional measurement approaches;
FIG. 5 shows a diagram indicating absolute phase error versus number of samples for the proposed measurement according to the preferred embodiment in comparison with conventional measurement approaches; and
FIG. 6 shows a diagram indicating frequency error versus measurement time for the proposed measurement according the preferred embodiment in comparison with conventional measurement approaches.



The preferred embodiment will now be described based on a frequency and phase estimation in a GSM mobile phone with GPS capability. However, it is to be noted that the proposed measurement scheme may as well be implemented in other electronic systems, such as CD systems or hard disc systems or the like, which are operated from independent clock oscillators.
FIG. 1 shows a schematic block diagram of a mobile device which includes a GSM communication system 10, such as a cell phone, and a position location system, such as a GPS system 20. The cellular communication system 10 is connected to a first antenna 15 and comprises suitable devices, hardware, and software for communicating with and/or detecting signals from cellular base stations, including a local oscillator and an automatic frequency control (AFC) system which locks a local oscillator to a cellular base frequency. Furthermore, a GPS system 20 is provided which is connected to a GPS antenna 25 to receive GPS signals which are transmitted at or near the ideal GPS frequency. The GPS system 20 comprises any suitable hardware and software for receiving and processing GPS signals and performs any calculations necessary to determine position using any suitable position location algorithm.
In order to observe and predict errors in the local oscillator and calibrate the GPS receiver with respect to the GPS signal, an error processing and calibration system 30 is provided which receives the GPS local oscillator frequency from the GPS local oscillator and also receives the cellular oscillator frequency. In a frequency comparison unit, the two frequencies are monitored and measurements are periodically provided based on counting operators of a first counting unit 32 for counting in response to the GPS local oscillator frequency and a second counter unit 33 for counting in response to the cellular oscillator frequency. In particular, the ratio of the frequencies can be computed using a frequency counting type procedure in which the frequency of the cellular oscillator is used as a time base and the GPS oscillator is used for delivering the frequency to be counted. As to achieve minimum measurement errors, the clock with the smaller frequency is used as gating clock with frequency fg and the clock with the higher frequency is used as collecting clock with frequency fc. However, it may also be vice versa. Typically, a fixed number of cycles of the time base are counted to establish a time interval. Based on the frequency and/or phase measurement, the error prediction and calibration system 30 may generate a correction signal C supplied to the GPS system 20. The correction signal may be supplied to the GPS local oscillator which in response adjusts the output GPS local oscillator frequency to correct for the predicted error. Alternatively, based on the frequency and/or phase measurement a correction of the GPS signal may be carried out by means of digital postprocessing.
In the following, the frequency and phase measurement process as performed in the error prediction and calibration system 30 is described in more detail with reference to FIGS. 2 and 3.
FIG. 2 shows a diagram indicating normalized phase ηc of the collecting clock versus normalized phase ηg of the gating clock, where k0 and k1 designate the first and last value of the gating counter spanning the measurement period {circumflex over (η)}c[k] designates the value of the collecting counter at the beginning of the k-th gating clock period. The line {tilde over (η)}c can be regarded as an approximation of ηc based on the initially described conventional approach, while the line ηc indicates the slope of the actual phase. The curve or line corresponds to the initially described regression line where the regression line samples {right arrow over (η)}c are marked by hollow dots. According to the preferred embodiment, the true non-linear {right arrow over (η)}c[k] and stepwise shape of the curve representing the counting operation of the collecting counter and thus the values of 10{circumflex over (η)}c the normalized phase is exploited for phase and frequency measurement purposes. In fact, the relationship of the corresponding counter values is given as follows:

{tilde over (η)}c[ηg[m]]=└a0+a1ηg[m]┘.  (8)

Hence, solving those values a0 and a1 which satisfy the relationship described by Eq. (8) yields in principle better estimates than obtained from the above conventional or regression line approaches. The tuples (a0, a1) which solve the above problem are members of a large set S. In theory, the set S contains an infinite number of tuples where the difference between the maximum and minimum values for the phase offset a0 and the slope a1 rely on various parameters like subset size M, frequency ratio of the gating and collecting clock, etc. Hence, for determination of virtually the whole set S, a search over a huge number of trial tuples has to be carried out. Depending on the granularity of the trial tuples, this search requires a significant complexity which makes it infeasible for practical use.
Thus, a low complexity approach is proposed. In addition, regarding the fact that with rising M and increasing measurement period the difference between all tuples in the set S becomes small, the search can be restricted to the determination of a single tuple (a0, a1) in the set S. That is, it is proposed not to determine the whole set S, but only a single member of that set.

{circumflex over (η)}c[ηg[m]]≦a0+a1ηg[m]<{circumflex over (η)}c[ηg[m]]+1.  (9)

In order to determine this tuple, the following relationship can be used:
After straightforward calculations, this equation yields that the slope a1 can vary for a given phase offset a0 in the range:




  
    
      
        
          
            
              
                
                  η
                  ^
                
                c
              
              ⁡
              
                [
                
                  
                    η
                    g
                  
                  ⁡
                  
                    [
                    m
                    ]
                  
                
                ]
              
            
            -
            
              a
              0
            
          
          
            
              η
              g
            
            ⁡
            
              [
              m
              ]
            
          
        
        ≤
        
          a
          1
        
        <
        
          
            
              
                η
                c
              
              ⁡
              
                [
                
                  
                    η
                    g
                  
                  ⁡
                  
                    [
                    m
                    ]
                  
                
                ]
              
            
            +
            1
            -
            
              a
              0
            
          
          
            
              η
              g
            
            ⁡
            
              [
              m
              ]
            
          
        
      
    
    
      
        (
        10
        )
      
    
  




while we get vice versa for the same phase offset's range for a given slope a1:

{circumflex over (η)}c[ηg[m]]−a1ηg[m]≦a0<{circumflex over (η)}c[ηg[m]]+1−a1ηg[m].  (11)

That is, minimum and maximum estimates a1,min, a1,max can be determined for the slope when having an estimate for the phase offset a0, and minimum and maximum estimates a0,min, a0,max can be determined for the phase offset when having an estimate for the slope a1.
Moreover, supposing that minimum and maximum estimates a0,min, a0,max are given for the phase offset, minimum and maximum estimates a1,min, a1,max for the slope can be obtained due to strict monotonicity of the left and right hand side of Eq. (10):




  
    
      
        
          
            a
            
              1
              ,
              min
            
          
          =
          
            
              
                
                  
                    η
                    ^
                  
                  c
                
                ⁡
                
                  [
                  
                    
                      η
                      g
                    
                    ⁡
                    
                      [
                      m
                      ]
                    
                  
                  ]
                
              
              -
              
                a
                
                  0
                  ,
                  max
                
              
            
            
              
                η
                g
              
              ⁡
              
                [
                m
                ]
              
            
          
        
        ,
        
          

        
        ⁢
        
          
            a
            
              1
              ,
              max
            
          
          =
          
            
              
                
                  
                    
                      η
                      ^
                    
                    c
                  
                  ⁡
                  
                    [
                    
                      
                        η
                        g
                      
                      ⁡
                      
                        [
                        m
                        ]
                      
                    
                    ]
                  
                
                +
                1
                -
                
                  a
                  
                    0
                    ,
                    min
                  
                
              
              
                
                  η
                  g
                
                ⁡
                
                  [
                  m
                  ]
                
              
            
            .
          
        
      
    
    
      
        (
        12
        )
      
    
  




In the same way the minimum and maximum estimates a0,min, a0,max can be determined for the phase offset if minimum and maximum estimates a1,min, a1,max are available for the slope from Eq. (11) as follows:

a0,min={circumflex over (η)}c[ηg[m]]−a1,maxηg[m], 

a0,max={circumflex over (η)}c[ηg[m]]+1−a1,minηg[m].  (13)

The above calculations can be carried out for all indices 0≦m≦M if appropriate a priori estimates are available. This task can be solved recursively in an iterative way. However, if a sub-optimal estimation or measurement is sufficient, the minimum and maximum value can be calculated only once and the estimation can be based on obtaining an average value or another final value based on the obtained minimum and maximum values.
In the following, the proposed measurement procedure is described with reference to FIG. 3.
FIG. 3 shows a schematic flow diagram of the frequency and phase measurement procedure according to the preferred embodiment.
In step S100 an initialization is performed by determining initial minimum and maximum estimates for the phase offset a0 and the frequency ratio or slope a1. The initial values may be obtained based on the following equations:




  
    
      
        
          
            a
            
              0
              ,
              min
            
          
          =
          
            
              φ
              n
            
            -
            
              Δ
              ⁢
              
                
              
              ⁢
              φ
            
          
        
        ⁢
        
          

        
        ⁢
        
          
            a
            
              0
              ,
              max
            
          
          =
          
            
              φ
              n
            
            +
            
              Δ
              ⁢
              
                
              
              ⁢
              φ
            
          
        
        ⁢
        
          

        
        ⁢
        
          
            a
            
              1
              ,
              min
            
          
          =
          
            
              
                f
                
                  c
                  ,
                  n
                
              
              
                f
                
                  g
                  ,
                  n
                
              
            
            -
            
              Δ
              ⁢
              
                
              
              ⁢
              f
            
          
        
        ⁢
        
          

        
        ⁢
        
          
            a
            
              1
              ,
              max
            
          
          =
          
            
              
                f
                
                  c
                  ,
                  n
                
              
              
                f
                
                  g
                  ,
                  n
                
              
            
            +
            
              Δ
              ⁢
              
                
              
              ⁢
              f
            
          
        
      
    
    
      
        (
        14
        )
      
    
  




where φn denotes the nominal phase offset, Δφ denotes the phase offset uncertainty, fc,n denotes the nominal collecting clock frequency, fg,n denotes the nominal gating clock frequency, and Δf denotes the frequency ratio uncertainty.

Then, in step S101 a running parameter m which is incremented for each sampling index is set to zero.
In step S102, minimum and maximum estimates for the frequency ratio based on the determined minimum and maximum estimates for the phase offset are determined. Additionally, in step S103, minimum and maximum estimates for the phase offset are determined based on the determined minimum and maximum estimates for the frequency ratio. The determinations in steps S102 and S103 are based on the following equations:




  
    
      
        
          
            a
            
              0
              ,
              min
            
          
          =
          
            min
            ⁡
            
              (
              
                
                  max
                  ⁡
                  
                    (
                    
                      
                        
                          
                            
                              η
                              ^
                            
                            c
                          
                          ⁡
                          
                            [
                            
                              
                                η
                                g
                              
                              ⁡
                              
                                [
                                m
                                ]
                              
                            
                            ]
                          
                        
                        -
                        
                          
                            a
                            
                              1
                              ,
                              max
                            
                          
                          ⁢
                          
                            
                              η
                              g
                            
                            ⁡
                            
                              [
                              m
                              ]
                            
                          
                        
                      
                      ,
                      
                        a
                        
                          0
                          ,
                          min
                        
                      
                    
                    )
                  
                
                ,
                
                  a
                  
                    0
                    ,
                    max
                  
                
              
              )
            
          
        
        ,
        
          

        
        ⁢
        
          
            a
            
              0
              ,
              max
            
          
          =
          
            max
            ⁡
            
              (
              
                
                  min
                  ⁡
                  
                    (
                    
                      
                        
                          
                            
                              η
                              ^
                            
                            c
                          
                          ⁡
                          
                            [
                            
                              
                                η
                                g
                              
                              ⁡
                              
                                [
                                m
                                ]
                              
                            
                            ]
                          
                        
                        -
                        
                          
                            a
                            
                              1
                              ,
                              min
                            
                          
                          ⁢
                          
                            
                              η
                              g
                            
                            ⁡
                            
                              [
                              m
                              ]
                            
                          
                        
                      
                      ,
                      
                        a
                        
                          0
                          ,
                          max
                        
                      
                    
                    )
                  
                
                ,
                
                  a
                  
                    0
                    ,
                    min
                  
                
              
              )
            
          
        
        ,
        
          

        
        ⁢
        
          
            a
            
              1
              ,
              min
            
          
          =
          
            min
            ⁡
            
              (
              
                
                  max
                  ⁡
                  
                    (
                    
                      
                        
                          
                            
                              
                                η
                                ^
                              
                              c
                            
                            ⁡
                            
                              [
                              
                                
                                  η
                                  g
                                
                                ⁡
                                
                                  [
                                  m
                                  ]
                                
                              
                              ]
                            
                          
                          -
                          
                            a
                            
                              0
                              ,
                              max
                            
                          
                        
                        
                          
                            η
                            g
                          
                          ⁡
                          
                            [
                            m
                            ]
                          
                        
                      
                      ,
                      
                        a
                        
                          1
                          ,
                          min
                        
                      
                    
                    )
                  
                
                ,
                
                  a
                  
                    1
                    ,
                    max
                  
                
              
              )
            
          
        
        ,
        
          

        
        ⁢
        
          
            a
            
              1
              ,
              max
            
          
          =
          
            
              max
              ⁡
              
                (
                
                  
                    min
                    ⁡
                    
                      (
                      
                        
                          
                            
                              
                                
                                  η
                                  ^
                                
                                c
                              
                              ⁡
                              
                                [
                                
                                  
                                    η
                                    g
                                  
                                  ⁡
                                  
                                    [
                                    m
                                    ]
                                  
                                
                                ]
                              
                            
                            +
                            1
                            -
                            
                              a
                              
                                0
                                ,
                                min
                              
                            
                          
                          
                            
                              η
                              g
                            
                            ⁡
                            
                              [
                              m
                              ]
                            
                          
                        
                        ,
                        
                          a
                          
                            1
                            ,
                            max
                          
                        
                      
                      )
                    
                  
                  ,
                  
                    a
                    
                      1
                      ,
                      min
                    
                  
                
                )
              
            
            .
          
        
      
    
    
      
        (
        15
        )
      
    
  




wherein the order of steps S102 and S103 may as well be changed.

Then, in step S104, the running parameter m is incremented for the next sampling index. In step S105, it is checked whether the maximum number m of samples of the collecting counter has been exceeded. If not, the procedure jumps back to step S102 for performing the calculations of the minimum and maximum estimates for the next sample. If the maximum number M has been exceeded in step S105, the procedure continues with step S106 or, if an iterative measurement is chosen, with a next one of a predetermined number of iterations of steps S101 to S105.
In the latter case, a second running variable and decision block has to be introduced into the flow diagram of FIG. 3 as a second loop for controlling the number of iterations.
Finally, in step S106, final estimates are derived for the phase offset a0 and the frequency ratio a1. This calculation may be based on an averaging step as defined in the following equations:




  
    
      
        
          
            a
            0
          
          =
          
            
              (
              
                
                  a
                  
                    0
                    ,
                    min
                  
                
                +
                
                  a
                  
                    0
                    ,
                    max
                  
                
              
              )
            
            2
          
        
        ,
        
          

        
        ⁢
        
          
            a
            1
          
          =
          
            
              
                (
                
                  
                    a
                    
                      1
                      ,
                      min
                    
                  
                  +
                  
                    a
                    
                      1
                      ,
                      max
                    
                  
                
                )
              
              2
            
            .
          
        
      
    
    
      
        (
        16
        )
      
    
  




The update rules in Eq. (15) are obtained from Eqs. (12) and (13) bearing in mind that a new minimum/maximum estimate has to be larger/smaller than or equal to the current minimum/maximum estimate and smaller/larger than or equal to the current maximum/minimum estimate.
The initialization values for the iteration in step S100 can be calculated from given system parameters. In fact, when starting the counters 32 and 33 of FIG. 1 randomly so that the phase offset is equally distributed for all possible values, the nominal phase offset φn and the phase offset uncertainty Δφ can be chosen as follows:




  
    
      
        
          
            φ
            n
          
          =
          
            
              f
              
                c
                ,
                n
              
            
            
              2
              ⁢
              
                
              
              ⁢
              
                f
                
                  g
                  ,
                  n
                
              
            
          
        
        ,
        
          

        
        ⁢
        
          
            Δ
            ⁢
            
              
            
            ⁢
            φ
          
          =
          
            
              
                f
                
                  c
                  ,
                  n
                
              
              
                2
                ⁢
                
                  
                
                ⁢
                
                  f
                  
                    g
                    ,
                    n
                  
                
              
            
            .
          
        
      
    
    
      
        (
        17
        )
      
    
  




The nominal collecting and gating clock frequencies are known a priori, and the corresponding frequency ratio uncertainty can be easily calculated from the maximum magnitude of the clock frequency offset:

Δfo=max|fc−fc,n|+max|fg−fg,n|  (18)

as follows:





  
    
      
        
          Δ
          ⁢
          
            
          
          ⁢
          f
        
        =
        
          
            
              Δ
              ⁢
              
                
              
              ⁢
              
                f
                o
              
            
            
              f
              
                c
                ,
                n
              
            
          
          .
        
      
    
    
      
        (
        19
        )
      
    
  




Alternatively, the initial values can be obtained by running another low complex estimation algorithm in advance which provides coarse estimates for the desired parameters, e.g. the initially described regression algorithm.
In the following, simulation results obtained for the above proposed iterative estimation or measurement approach are described in connection with FIGS. 4 to 6. In these simulations, a nominal collection clock frequency of fc,n=26 MHz and a nominal gating clock frequency of fg,n=5.265 MHz have been chosen. In addition, in order to account for an offset of the actual clock frequency from the nominal clock frequency, the true gating clock frequency fg is offset by up to ±40 ppm (parts per million), i.e., ±210 Hz, from its nominal value, while fc=fc,n is chosen for the collecting clock frequency.
First, a fixed measurement time of Tmeas=1 s has been chosen. M=10, . . . , 104 values have been recorded from the collecting counter taken from a so-called jittered grid as described in Peter Bode, Alexander Lampe, Markus Helfenstein, and Michael Gollnick, “Improved Method for Measuring Frequency ratios in GSM Mobile Phones”, in Proc. IEEE Custom Integrated Circuits Conference, Orlando, Fla., October 2004.
For each value M 1000 trials have been carried out while choosing for each trial the true gating clock frequency equally likely from the interval [5.265 MHz−210. Hz, 5.265 MHz+210 Hz]. In addition, for each trial the phase offset has been chosen equally likely from the interval [0, fc,n/fg,n], too.
The phase offset a0 and frequency ratio a1 were estimated for each trial with the regression algorithm as well as the proposed iterative algorithm according to the preferred embodiment yielding a0,reg and a1,reg as well a0,iter and a1,iter, respectively. For the iterative algorithm three iterations were carried out, that is, in the flow diagram of FIG. 3, the loop procedure of steps S101 to S105 has been carried out three times.
From the frequency ratios, the actual gating clock frequency is subsequently obtained as:




  
    
      
        
          f
          
            g
            ,
            
              reg
              /
              iter
            
          
        
        =
        
          
            
              f
              c
            
            
              a
              
                1
                ,
                
                  reg
                  /
                  iter
                
              
            
          
          .
        
      
    
    
      
        (
        20
        )
      
    
  




The corresponding relative frequency error and absolute phase offset error can be obtained as follows:




  
    
      
        
          
            ɛ
            
              f
              ,
              
                reg
                /
                iter
              
            
          
          =
          
            
              1
              -
              
                
                  f
                  
                    g
                    ,
                    
                      reg
                      /
                      iter
                    
                  
                
                
                  f
                  g
                
              
            
            =
            
              1
              -
              
                
                  
                    f
                    c
                  
                  
                    f
                    g
                  
                
                ·
                
                  1
                  
                    a
                    
                      1
                      ,
                      
                        reg
                        /
                        iter
                      
                    
                  
                
              
            
          
        
        ,
        
          

        
        ⁢
        
          
            ɛ
            
              φ
              ,
              
                reg
                /
                iter
              
            
          
          =
          
            φ
            -
            
              
                a
                
                  0
                  ,
                  
                    reg
                    /
                    iter
                  
                
              
              .
            
          
        
      
    
    
      
        (
        21
        )
      
    
  




FIGS. 4 and 5 show the resulting RMS value of εf in ppm versus the number M of samples, and εφ versus the number M of samples, respectively, for the fixed total measurement time of Tmeas=1 s. The RMS value is averaged over all trials for one particular index set cardinality M. For comparison, in FIG. 4, the relative frequency estimation error resulting from the initially described conventional method is also depicted. In particular, the continuous line indicates the results of the conventional method c, the dashed line indicates the results of the regression method r, and the dash-dotted line indicates the results of proposed iterative method i.
It can be gathered from FIGS. 4 and 5 that the proposed method i outperforms the conventional method c as well as the regression method r by orders of magnitude with rising numbers of samples M. In fact, while the frequency error of the regression method r is almost proportional to √{square root over (M)}, the frequency error of the iterative method i is almost proportional to M. In addition, the phase error decreases proportional to rising M when the iterative method i is applied while it is constant for the regression method r. It is noted that no phase estimation error curve can be given for the conventional method C, as it doesn't provide a phase estimate.
The superiority of the new non-linear method i is also confirmed by the results given in FIG. 6. It shows a diagram of RMS frequency error versus measurement time with a sampling number M=100. Here, the RMS frequency estimation errors are compared for different measurement times Tmeas=0.01 s, . . . , 1 s, while the number of samples is fixed to M=100. For each value M 1000 trials have been carried out while choosing for each trial the true gating clock frequency equally likely from the interval [5.265 MHz-210 Hz, 5.265 MHz+210 Hz]. In addition, for each trial the phase offset is chosen equally likely from the interval [0, fc,n/fg,n], too. As before, three iterations were carried out for the proposed non-linear iterative method i.
In summary, an accurate frequency and phase measurement algorithm is proposed which is based on a non-linear technique, optionally involving iterations. Compared to conventional approaches as well as recently proposed regression based solutions, it can be shown that the estimation error can be improved by up to orders of magnitude with almost negligible complexity increase in signal processing.
It is noted that the present invention is not restricted to the above preferred embodiment but can be used in any electronic circuit which is operated from independent clock oscillators. Furthermore, the proposed method is not restricted to the calculation of the minimum and maximum estimates as expressed in equations (12) to (16). Rather, any known approximation of the non-linear stepwise function indicated in FIG. 2 is considered to be covered by the present invention. The preferred embodiments may thus vary within the scope of the attached claims.
It must further be noted that the term ‘comprising’ when used in the specification including the claims is intended to specify the presence of stated features, means, steps or components, but does not exclude the presence or addition of one or more other features, means, steps, components or groups thereof. Furthermore, the word ‘a’ or ‘an’ preceding an element in a claim does not exclude the presence of a plurality of such elements. Moreover, any reference signs do not limit the scope of the claims. The invention can be implemented by means of both hardware and software, and several ‘means’ may be represented by the same item or hardware.

## Claims

1. An apparatus for measuring at least one of a frequency ratio and a phase offset, said apparatus comprising:
gating control means for generating a gating clock based on said at least one of the frequency ratio and the phase offset;
collecting control means for generating a collecting clock at a frequency derived from a reference signal; and
estimating means for estimating said frequency ratio by calculating maximum and minimum estimates for said frequency ratio based at least on calculated minimum and maximum estimates of said phase offset, respectively, and for estimating said phase offset by calculating maximum and minimum estimates for said phase offset based at least on calculated minimum and maximum estimates of said frequency ratio, respectively, wherein said frequency ratio is a ratio between frequencies of said collecting clock and said gating clock, and wherein said phase offset is an offset between said collecting clock and said gating clock.

2. An apparatus as claimed in claim 1, wherein said estimating means comprises first counter means for counting said collecting clock and second counter means for counting said gating clock, and wherein said estimating means is arranged to perform said estimation based on count values of said first and second counter means at an instance in time.

3. An apparatus according to claim 2, wherein said estimating means estimates both of said frequency ratio and said phase offset by an iterative process utilizing the count values of said first and second counter means at the instance in time.

4. An apparatus according to claim 1, wherein said estimating means is arranged to calculate said maximum and minimum estimates for said phase offset between said collecting clock and said gating clock based at least on calculated minimum and maximum estimates of said phase offset.

5. An apparatus according to claim 4, wherein said estimating means is arranged to calculate said maximum and minimum estimates for said frequency ratio based at least on calculated minimum and maximum estimates of said frequency ratio.

6. An apparatus according to claim 5, wherein said estimating means is arranged to average said maximum and minimum estimates of said frequency ratio to obtain said frequency and average said maximum and minimum estimates of said phase ratio to obtain said phase.

7. An apparatus according to claim 5, wherein said estimating means is arranged to derive initial values of said minimum and maximum values from estimates of another estimation function or from given system parameters.

8. An apparatus according to claim 7, wherein said other estimation function is based on a regression.

9. An apparatus according claim 1, wherein said at least one of the frequency ratio and the phase offset is used as gating clock and said reference signal is used as collecting clock.

10. A method of measuring at least one of a frequency ratio and a phase offset, said method comprising:
generating a gating clock based on said at least one of the frequency ratio and the phase offset;
generating a collecting clock at a frequency derived from a reference signal;
calculating minimum and maximum estimates for said frequency ratio based at least on maximum and minimum estimates of said phase offset, respectively, said frequency ratio being a ratio between frequencies of said collecting clock and said gating clock;
calculating minimum and maximum estimates for said phase offset based at least on maximum and minimum estimates of said frequency ratio, respectively, said phase offset being an offset between said collecting clock and said gating clock;
estimating said frequency ratio based at least on said calculated minimum and maximum estimates for said frequency ratio; and
estimating said phase offset based at least on said calculated minimum and maximum estimates for said phase offset, wherein at least one of the generating, calculating, and estimating steps is performed by at least one processor.

11. The method of claim 10, wherein said at least one of the frequency ratio and the phase offset is used as said gating clock and said reference signal is used as said collecting clock.

12. The method of claim 10, comprising:
sampling a counter of said collecting clock and a counter of the said gating clock at an instance in time.

13. The method of claim 10 wherein estimating said frequency ratio based at least on said calculated minimum and maximum estimates for said frequency ratio includes determining said frequency ratio from an average of said calculated minimum and maximum estimates for said frequency ratio.

14. The method of claim 10 wherein estimating said phase offset based at least on said calculated minimum and maximum estimates for said phase offset includes determining said frequency ratio from an average of said calculated minimum and maximum estimates for said phase offset.

15. The method of claim 10 wherein estimating said frequency ratio based at least on said calculated minimum and maximum estimates for said frequency ratio and estimating said phase offset based at least on said calculated minimum and maximum estimates for said phase offset includes deriving initial values of said minimum and maximum estimates for said frequency ratio and said minimum and maximum estimates for said phase offset.

16. The method of claim 10, wherein the at least one processor includes one or more of dedicated hardware, a microprocessor, and a digital signal processor.

17. A non-transitory computer-readable medium having code for causing a processor to implement a method of measuring a frequency ratio and a phase offset, comprising:
generating a gating clock based on said measuring the frequency ratio and a phase offset;
generating a collecting clock at a frequency derived from a reference signal;
calculating minimum and maximum estimates for said frequency ratio based at least on maximum and minimum estimates of said phase offset, respectively, said frequency ratio being a ratio between frequencies of said collecting clock and said gating clock;
calculating minimum and maximum estimates for said phase offset based at least on maximum and minimum estimates of said frequency ratio, respectively, said phase offset being an offset between said collecting clock and said gating clock;
estimating said frequency ratio based at least on said calculated minimum and maximum estimates for said frequency ratio; and
estimating said phase offset based at least on said calculated minimum and maximum estimates for said phase offset.

18. The computer-readable medium of claim 17 wherein the code comprises:
sampling a counter of said collecting clock and a counter of the said gating clock at an instance in time.

19. The computer-readable medium of claim 17 wherein estimating said frequency ratio based at least on said calculated minimum and maximum estimates for said frequency ratio includes determining said frequency ratio from an average of said calculated minimum and maximum estimates for said frequency ratio.

20. The computer-readable medium of claim 17 wherein estimating said phase offset based at least on said calculated minimum and maximum estimates for said phase offset includes determining said frequency ratio from an average of said calculated minimum and maximum estimates for said phase offset.

21. The computer-readable medium of claim 17 wherein estimating said frequency ratio based at least on said calculated minimum and maximum estimates for said frequency ratio and estimating said phase offset based at least on said calculated minimum and maximum estimates for said phase offset includes deriving initial values of said minimum and maximum estimates for said frequency ratio and said minimum and maximum estimates for said phase offset.

22. A non-transitory computer-readable medium having code for causing a processor to implement a method of measuring a frequency ratio and a phase offset, comprising:
generating a gating clock based on said measuring the frequency ratio and a phase offset;
generating a collecting clock at a frequency derived from a reference signal;
estimating said frequency ratio and said phase offset by approximating a relationship between said collecting clock and said gating clock based on a non-linear step- shaped function;
providing a correction to the gating clock based at least on the frequency ratio and the phase offset, and wherein estimating said frequency ratio and said phase further includes:
prior to providing the correction, collecting a set of pairs of counter values, each pair of counter values including a respective value of a count of a number of cycles of the gating clock at an instance of time and a respective value of a count of a number of cycles of the collecting clock at the same instance of time, wherein the set of pairs of counter values includes a number (M) of member pairs, where M is greater than one;
prior to providing the correction, recursively determining a current maximum value and a current minimum value of the phase offset for each pair of counter values based at least on a previous maximum value and a previous minimum value of the phase offset and a previous maximum value and a previous minimum value of the frequency ratio of the collecting clock relative to the gating clock, wherein at least (M−1) of the respective previous minimum and maximum values of the phase offset are determined based at least on the set of counter values, and wherein at least (M−1) of the respective previous minimum and maximum values of the frequency ratio are determined based at least on the set of counter values; and
prior to providing the correction, recursively determining a current maximum value and a current minimum value of the frequency ratio for each pair of counter values based at least on the previous maximum value and the previous minimum value of the phase offset and the previous maximum value and the previous minimum value of a frequency ratio.

23. The computer-readable medium of claim 22 wherein the code further comprises:
prior to determining the current maximum value and the current minimum value of the phase offset and prior to determining the current maximum value and the current minimum value of the frequency ratio,
estimating a first maximum value and a first minimum value of the phase offset, and
estimating a first maximum value and a first minimum value of the frequency ratio.

24. The computer-readable medium of claim 22 wherein the code further comprises:
determining a final value of the phase offset based at least on the current maximum value and the current minimum value of the phase offset; and
determining the final value the frequency ratio based at least on the current maximum value and the current minimum value of the frequency ratio.

25. The computer-readable medium of claim 22 wherein for each pair of counter values, the current maximum value and the current minimum value of the phase offset is determined based at least on the respective pair of counter values and the current maximum value and the current minimum value of the frequency ratio is determined based at least on the respective pair of counter values.

26. The computer-readable medium of claim 25 wherein the code further comprises:
repeating for a number of iterations,
determining the current maximum value and the current minimum value of the phase offset for each pair of counter values, and
determining the current maximum value and the current minimum value of the frequency ratio for each pair of counter values.

27. A method of measuring at least one of a frequency ratio and a phase offset, comprising:
generating a gating clock based on said at least one of the frequency ratio and the phase offset;
generating a collecting clock at a frequency derived from a reference signal;
estimating the at least one of said frequency ratio and said phase offset by approximating a relationship between said collecting clock and said gating clock based on a non- linear step-shaped function;
providing a correction to the gating clock based at least on the frequency ratio and the phase offset, and wherein estimating said frequency and said phase further includes:
prior to providing the correction, collecting a set of pairs of counter values, each pair of counter values including a respective value of a count of a number of cycles of the gating clock at an instance of time and a respective value of a count of a number of cycles of the collecting clock at the same instance of time, wherein the set of pairs of counter values includes a number (M) of member pairs, where M is greater than one;
prior to providing the correction, recursively determining a current maximum value and a current minimum value of the phase offset for each pair of counter values based at least on a previous maximum value and a previous minimum value of the phase offset and a previous maximum value and a previous minimum value of the frequency ratio of the collecting clock relative to the gating clock, wherein at least (M−1) of the respective previous minimum and maximum values of the phase offset are determined based at least on the set of counter values, and wherein at least (M−1) of the respective previous minimum and maximum values of the frequency ratio are determined based at least on the set of counter values; and
prior to providing the correction, recursively determining a current maximum value and a current minimum value of the frequency ratio for each pair of counter values based at least on the previous maximum value and the previous minimum value of the phase offset and the previous maximum value and the previous minimum value of the frequency ratio, wherein at least one of the generating, estimating, and providing steps is performed by at least one processor.

28. The method of claim 27, further comprising:
prior to determining the current maximum value and the current minimum value of the phase offset and prior to determining the current maximum value and the current minimum value of the frequency ratio,
estimating a first maximum value and a first minimum value of the frequency offset, and
estimating a first maximum value and a first minimum value of the frequency ratio.

29. The method of claim 27, further comprising:
determining a final value of the phase offset based at least on the current maximum value and the current minimum value of the phase offset; and
determining the final value the frequency ratio based at least on the current maximum value and the current minimum value of the frequency ratio.

30. The method of claim 27 wherein for each pair of counter values, the current maximum value and the current minimum value of the phase offset is determined based at least on the respective pair of counter values and the current maximum value and the current minimum value of the frequency ratio is determined is also based on the respective pair of counter values.

31. The method of claim 27, further comprising:
repeating for a number of iterations,
determining the current maximum value and the current minimum value of the phase offset for each pair of counter values, and
determining the current maximum value and the current minimum value of the frequency ratio for each pair of counter values.

32. The method of claim 27, wherein the at least one processor includes one or more of dedicated hardware, a microprocessor, and a digital signal processor.

33. A method of generating a correction to a gating clock, comprising:
counting a first number of cycles of a collecting clock over a time period that is a fixed number of cycles of the gating clock with a collecting clock counter, the collecting clock having a frequency higher than a frequency of the gating clock;
counting a second number of cycles of the gating clock over the same time period with a gating clock counter;
collecting a set of pairs of counter values, each pair of counter values includes a respective value of the collecting clock counter and a respective value of the gating clock counter at an instance in time during the time period;
estimating a frequency ratio of the collecting clock relative to the gating clock and a phase offset of the gating clock based at least on a counter value of the collecting clock counter and a counter value of the gating clock counter;
determining a current value of the frequency ratio based at least on a previous value of the frequency ratio and a previous value of the phase offset, wherein determining the current value of the frequency ratio includes determining a current value of the phase offset for each respective pair of counter values;
determining a current value of the phase offset based at least on the previous value of the frequency ratio and the previous value of the phase offset, wherein determining the current value of the phase offset includes determining the current value of the frequency ratio for each respective pair of counter values; and
calibrating the gating clock based on the current value of the phase offset and the frequency ratio, wherein at least one of the counting, collecting, estimating, determining, and calibrating steps is performed by at least one processor.

34. The method of claim 33 wherein determining the current value of the phase offset for each respective pair of counter values includes determining a current minimum value of the phase offset and a current maximum value of the phase offset for each respective pair of counter values based at least on a previous maximum value and a previous minimum value of the phase offset and a previous maximum value and a previous minimum value of a frequency ratio; and wherein determining the current value of the frequency ratio for each respective pair of counter values includes determining a current minimum value of the frequency ratio and a current maximum value of the frequency ratio for each respective pair of counter values based at least on the previous maximum value and the previous minimum value of the phase offset and the previous maximum value and the previous minimum value of a frequency ratio.

35. The method of claim 33, wherein the at least one processor includes one or more of dedicated hardware, a microprocessor, and a digital signal processor.