A kind of USB is from the system clock automated calibration system of equipment and method
Technical field
The present invention relates to SOC integrated circuit (IC) design field, particularly relate to computer communication USB interface, more specifically, it relates to a kind of USB from the system clock automated calibration system of equipment and method.
Background technology
The electronic product of a large amount of low side adopts USB1.1 interface, but USB interface requires higher to system clock accuracy, needs to reach within positive and negative 0.5% just can have stronger compatibility.
Have an external crystal-controlled oscillation in major applications as clock source, inner also have a PLL to carry out frequency multiplication, exports 48M clock and use to USB controller.If this external crystal-controlled oscillation save, the cost of product outline schemes has one obviously to be reduced, and it is smaller and more exquisite to be conducive to that final product design is obtained.If chip internal has a high precision clock ring to shake, just this crystal oscillator can be save, but will accomplish that high precision clock ring like this shakes, consider temperature, voltage and process deviation, be almost impossible.If therefore have a technology can shake to internal clocking ring carry out automatic calibration, no matter temperature, voltage and technique how deviation, all remains near 48M, so just can realize the target saving external crystal-controlled oscillation.
Current USB1.1 is generally calibrated by outside from the system clock of equipment, or when producing, test writes calibration value to non-volatile memory body, or the frequency of a generation high-frequency ratio as good hundreds of million carries out sampling frequency division.
The scheme had at present is produced the clock of hundreds of million, Delta_Sigma fractional frequency division is carried out to it, use 8 frequency divisions of this high frequency clock to go to detect USB differential bus simultaneously, feed back accordingly, calibrate decimal frequency divider, obtain the system clock of final USB.The program is not use clock accurately after calibration when detecting USB differential bus, and directly adopts 8 frequency divisions of high frequency clock, there is the possibility of sample error, usb compatible may be caused poor.The high frequency clock that the program must produce higher than 250M in addition can make power consumption become large.
Summary of the invention
The object of the invention is to overcome deficiency of the prior art, the system clock automated calibration system of a kind of USB from equipment and method are provided.
The object of the invention is to be achieved through the following technical solutions: this USB is from the system clock automated calibration system of equipment, this system comprises 48M clock generator, USB Frame Synchronization Test module, USB1.1 physical layer interface, counter, comparer, reference current regulator, non-volatile memory body and the steering logic that powers on, and wherein 48M clock generator is that the clock ring of a generated clock frequency shakes; USB Frame Synchronization Test module for detecting the frame synchronization bag of USB, and produces the pulse of fixed frequency, is supplied to the periodicity of rolling counters forward 48M clock as basic pulse; USB1.1 physical layer interface is used for converting the analog difference signal of USB to digital difference signal; Counter for count USB Frame Synchronization Test module produce basic pulse between periodicity; Comparer for the periodicity that compares counter and obtain and theoretical periodicity, or judges that clock frequency that current 48M clock generator generates is higher than lower than desirable 48M frequency thus; Reference current regulator is an arithmetic logic, corresponding value is calculated by changing the reference current of 48M clock generator inside according to the comparative result of comparer, make ring shake output frequency rise or reduce, 48M clock generator output frequency is adjusted it and is stabilized in 48M.
Further, 48M clock generator is that a clock ring shakes, and generated frequency is about 48M clock.This clock is supplied to USB Frame Synchronization Test module sum counter, simultaneously as the system clock of USB controller.
Further, non-volatile memory body is the non-volatile memory bodies such as flash or OTP, production test can be coordinated to join an initial value to 48M clock generator, due to production technology deviation, there is upper lower deviation up and down in the output clock of the 48M clock generator of each chips, if deviation ratio is comparatively large, the frame synchronization bag that USB Frame Synchronization Test module detects USB can be affected, therefore 48M clock initial deviation can be made to reduce to the preliminary adjustment of 48M clock generator during production test.
Further, non-volatile memory body is for accessing the initial calibration value of 48M clock generator, the steering logic that powers on is the Read Controller of a non-volatile memory body, automatically reference value is read from non-volatile memory body when system electrification, corresponding reference current is joined to 48M clock generator, make its output clock frequency have an initial calibration value, then reference current regulator makes it be stabilized in 48M to 48M clock generator adjustment output frequency.
USB of the present invention is from the system clock automatic calibrating method of equipment, and the concrete steps of the method are as follows:
1, system electrification, 48M clock generator is started working and is exported initial clock;
2, USB Frame Synchronization Test module receives the frame synchronization bag of PC.
3, counter and comparer work and Calculation Basis Current adjustment value adjusts its output clock frequency to 48M clock generator.
4, ceaselessly repeat 2 and 3 steps, meet the demands until export 48M frequency.
The invention has the beneficial effects as follows: the initial calibration value of 48M clock generator is stored in non-volatile memory body, reached the object of frequency adjustment by the reference current of reference current regulator adjustment 48M clock generator; USB Frame Synchronization Test module produces basic pulse as the benchmark of adjusting frequency; Do not need external crystal oscillator, inner generate 48M dominant frequency clock and not with external environment condition change all the time automatically regulating frequency to 48M.
Accompanying drawing explanation
Fig. 1 is system architecture diagram;
Embodiment
Below in conjunction with drawings and Examples, the present invention is described further.Although the present invention will be described in conjunction with preferred embodiment, should know, and not represent and limit the invention in described embodiment.On the contrary, the present invention will contain can be included in attached claims limit scope of the present invention in alternative, modified and equivalent.
The present embodiment, for-AS508HUSBKEY special chip, illustrates practicing of the art of this patent below in conjunction with Fig. 1:
AS508H is by USB interface and PC connecting communication, and PC is the main equipment end of USB interface, AS508H be USB interface from equipment end.
After AS508H is inserted into USB port as equipment, chip powers on simultaneously, and carries out resetting and initialization, and PC can ceaselessly send frame synchronization bag and packet to equipment end simultaneously.
After chip electrification reset, steering logic 8 can read a value of write in advance from one of non-volatile memory body 7 fixing address, revaluate is set to 10 bit widths, corresponding reference current is joined to 48M clock generator 1, its output clock frequency is made to have an initial value, during AS508H passes through, survey can make this initial value remain in positive and negative 2% scope of 48M, can ensure the correct reception next to the frame synchronization bag of usb bus data firm incipient stage.
PC gives the frame synchronization bag come and is converted to digital difference signal through USB1.1 physical layer interface 3, this signal gives USB Frame Synchronization Test module 2, when it receives frame synchronization bag, corresponding pulse can be generated, frequency due to frame synchronization bag is fixing, and the pulse therefore generated can be supplied to as a basic pulse periodicity that counter 4 counts 48M clock.
The desirable count cycle of 48M frequency to this basic pulse is fixing, the clock that 48M clock generator exports must exist upper inclined or partially lower, the periodicity that comparer 5 counts for the periodicity that compares counter 4 and obtain and theoretical 48M, or judge that clock frequency that current 48M clock generator 1 generates is higher than lower than desirable 48M frequency thus.
Reference current regulator 6 calculates corresponding value to the adjustment of 48M clock generator 1 output frequency according to the comparative result of comparer 5, and Regulation mechanism is the reference current changing 48M clock generator 1 inside, makes the ring output frequency that shakes rise or reduce.Because USB work clock 48M substantially can have stable compatible preferably within positive and negative 0.5% deviation, the program judges when 48M clock generator 1 output frequency is just do not carry out frequency adjustment within 48M positive and negative 0.2%, just frequency adjustment is carried out when output frequency deviation exports 0.2%, can guarantee that this USB can produce very stable 48M system clock from equipment not having the condition of external crystal-controlled oscillation, and make USB interface communication normal table.
During chip operation environmental change, or the external environment condition change such as such as voltage temperature can make reference current generation deviation, thus affects the output clock frequency of 48M clock generator 1.This automatic regulating machine can very promptly adjust within 48M clock generator 1 makes its output clock remain at 48M positive and negative 0.2% under the condition not connecing external crystal-controlled oscillation.USB saves a crystal oscillator from device product and can play huge commercial interest to cost control.
Concrete implementation step is as follows:
1, chip powers on, and 48M clock generator 1 is started working and exported initial clock.
2, USB Frame Synchronization Test module 2 receives the frame synchronization bag of PC.
3, counter and comparer work and Calculation Basis Current adjustment value adjusts its output clock frequency to 48M clock generator 1.
4, ceaselessly repeat 2 and 3 steps, meet the demands until export 48M frequency.
Terminological interpretation: USB: Chip Operating System.