Patent ID: 8634506

Claim:
A method for automatically calibrating frequency, the method comprising: generating a series of digital data according to a pair of differential signals received from a low-speed Universal Serial Bus (USB); outputting a first pulse and a first predetermined value according to a keep-alive end-of-packet (EOP) of a plurality of keep-alive end-of-packets when the keep-alive end-of-packet is detected at a beginning of the series of digital data, wherein width of the first pulse is equal to width of the keep-alive end-of-packet; counting a first number of clocks generated by an oscillator during the first pulse; comparing the first number of clocks with the first predetermined value to generate a first comparison result; calibrating coarsely a frequency of the oscillator according to the first comparison result; outputting a second pulse and a second predetermined value according to a SYNC pattern when the SYNC pattern is detected from the series of digital data after the first pulse is generated, wherein width of the second pulse is shorter than width of the SYNC pattern; counting and accumulating a second number of clocks generated by the oscillator during the second pulse; counting a number of the second pulse; stopping counting and accumulating the second number of clocks when the number of the second pulse is equal to K, wherein K is a positive integer and larger than 2; comparing an accumulated second number of clocks with the second predetermined value to generate a second comparison result, wherein the accumulated second number of clocks is equal to K multiple of the second number of clocks generated by the oscillator during the second pulse; calibrating finely the frequency of the oscillator according to the second comparison result; and clearing the number of the second pulses.