Patent ID: 8595543

Claim:
A method for trimming an internal oscillator of a USB device that generates a clock signal as a frequency source of the USB device, the method comprising the steps of: (a) detecting an end of packet from an input data stream for initializing a counter; (b) detecting an input packet in the data stream for identifying whether or not the input packet is a token packet, and if the input packet is not a token packet, going back to the step (a), otherwise proceeding with the following steps; (c) identifying whether or not the input packet has a packet identifier which defines a start of frame token packet, and if the input packet is a start of frame token packet, sequentially controlling the counter to carry out clock counting on the clock signal, otherwise going back to the step (a); (d) detecting a next start of frame token packet in the data stream for latching the counter to thereby obtain a count value; and (e) comparing the count value with a reference value for trimming a clock frequency of the internal oscillator; wherein said count value is obtained responsive solely to a determination of whether the input packet is a start of frame packet, and the step (b) comprises the steps of: counting the number of clocks in the clock signal during an interval between a first rising edge and a third rising edge of a positive differential signal carrying the data stream for generating a first clock count value; counting the number of clocks in the clock signal during an interval between the first rising edge and a fourth rising edge of the positive differential signal for generating a second clock count value; and if the first clock count value is one-half of the second clock count value, concluding the input packet as a token packet.