Much measurement C functions of time of summary can’t be used in ARM. Some can be used, it is the base when the system is real too the clock RTC ,So the shortest chronomere can only reach 10-2s. As a common accurate way to measure time, in order to make the tolerance of meticulous time, can consider launching ARM chip built-in WatchDog and realizing the real-time clock function expanded, and generalize to the use that the procedure delays time accurately, remedy the deficiency of the existing C function. This text makes analysis to this, and provide the concrete experiment to describe.
Keyword Accurate the intersection of time and accurate measurement the intersection of ARM and real-time clock expand, guard the gate dog count,
In ARM system. Need accurate time measurement sometimes. Common,it is to fetch time C function gettime ,etc. Not merely the commonability is bad must include the head file DOS. H, and does not support Unix, Linux and standard C ,Not obviously suitable for ARM system; The more problematic one is, it shortest time can only reach grade for 10-2 second, can’t offer the graduation of shorter time. Basic in that: The function the intersection of base and clock RTC when the system is real ,it and adopt usually at RTC standardized clock and watch shake brilliantly, 32 frequency. 768 kHz.
But much application time related to μ’s s grade measures, this RTC and based on the function of time of it that is standardization is powerless. How much question I am in the course of transplanting the experiment to ARM system of DES algorithm, meet quantitatively and assess and encrypt algorithms time consumingly, find that really can’t solve with the above-mentioned regular C function. Through to the investigation of ARM chip structure, find its built-in WatchDog system drives with the systematic clock, quantitative performance should be very good, it should be enough too to distinguish the meticulous intensity in the time interval. Then according to the explanation in the former producer data manual of ARM chip used, using WatchDog writes one’s own timing function, it is more convenient to use too. Consider ARM chip have built-in to guard the gate dog, I think this kind of method can be regarded as a good ” transitionality ” The solution, so introduce here, make a comment for counterparts’ reference.
A principle of measurement
Dog of guarding the gate in ARM chip, its primitive function is to monitor some overtime when CPU core runs. These the emergences of overtime,usually it interfered with and systematic error,etc. cause procedure operation confusion. Happen the situation, guard the gate dog ask for, cut off the service or send out and reset the pulse to restart the system. In order to achieve the such goal, its principle of timing must be independent of any process in the system. In fact, WatchDog is the independent hardware logic, its pulse of timing is taken from the systematic master clock directly, so it possesses real-time character and independence like RTC, it is rational that the timing system of the dog of using and guarding the gate realizes high-accuracy time measurement.
Develop the board type as NETARM300 with ARM that S3C4480X used in the experiment is used by example this experiment first ,Have a talk operation principle to guard the gate dog specifically. Its block diagram of principle, MCLK namely systematic master clock in the picture.
Can find out systematic the intersection of master clock and MCLK pass programmable pre- frequency division and after the available fixed frequency division in picture, enter WTCNT the timing counter of the hardware system, 16 Count. According to the device manual, count the time interval t_watchdog =l/ MCLK/ Prescaler value1 /Division_factor . In the type, the fetching value of the parameter Prescakr value is as O- 28 – l; Division_factor has fetching value of 16, 32, 64, 128 four kinds. If reset signals to export and allow namely puts 1 in the location 0 of WTCON ,Once the count of the counter WTCNT exceeds the range that WTDAT allows, guards the gate the dog will reset CPU s. Have shielded and lost this kind to reset and cut off request function in the course of this experiment, only let it count to the pulse.
Have already provided in the relevant every definition pictures which controlled the register WTCON if need to explain that can consult the device manual in detail, such as references [3 ] ,All in order to keep the location other, it is O to put completely.
As for the calculation of MCLK concrete value, the ones that can be checked in the system shake the parameter frequency brilliantly ,Read PLL register of the systematic clock such as PLLCON of S3C44BOX And then can be regarded as. The methods to calculate have all already been provided in the concrete ARM chip manual.
2 measures algorithm realizing and experimental result
The value that dog’s timer controls the register WT-CON as noted previously that the ones that set up according to the necessary parameter guard the gate ,Open, guard the gate dog’s timer before the code section to be measured is carried out; Wait for it finish, close, guard the gate the intersection of dog and timer, read value of WTCNT, can be regarded as running time. As a concrete example, my algorithms realized in experiment are as follows:
1Timing algorithm
2Application
Need pointing out: Should until person who have keep, recover and then WTCON after finishing in measurement originally before value to change WTCON. The reason why emphasize this, because dog’s function that the system will be probably using and guarding the gate elsewhere.
In the experiment, adopt DES 3 times to encrypt to the string that the length is the 189 bytes. The key length is 15, the encryption time to measure is 28832μ s, it is 28 896μ s to decipher time. Shorten the string length, the encryption time to measure basically presents and changes linearly: The string length a 107 bytes encrypts time consuming 16 928μ s when the other places do not change, decipher time consuming 16 948μ s; The string length a 41 bytes encrypts time consuming 7 424μ s when the other places do not change, decipher time consuming 7 424μ s. As to the string of the same length, the influence on encrypting / deciphering time of change of the key length is not very great.
What deserves to be mentioned is, while just beginning the experiment, have the string encrypted to choose for 190 bytes and 75 bytes respectively, it measures time consuming to be 34 032μ s and 16 928μ s separately, obviously fall far short of relation of multiplication. Analyze, find Uan_Printf question lie in, encrypt in the middle of the algorithm, print sentences originally behind the procedure” ‘ ” \ ncounting begin …! ! ! ” ” Have. Think it to be time consuming and few originally, remove in encrypting algorithm it; Retry remove, reduce while being great while being time consuming, 29 600 μ s and 12 496μ s respectively, multiplication, the intersection of time and expectancy of multiplication conform basically with several character. The testing of the above, also make authors learn that printing sentences takes up 4432μ s. Revise the condition, continue the experiment: When it is extended into for 4 fold that the above-mentioned byte which prints the sentence is counted, measure this sentence time consuming 17728μ s. It is obvious, are counted and basically directly proportional to with the byte which prints the content time consumingly; In addition, this kind prints sentences with encrypting / deciphering algorithms to compare, does not only take a little time assuming as a matter of course. Above-mentioned data and the intersection of PC and bunches of the intersection of mouth and arrangement of rate of Potter communicated have obvious relation. The real test result is: Potter leads to drop to 57 600 bps from 115 200bps, do not have difference that can be perceived.
3 measurement methods are discussed
ARM disposes and guards the gate the dog is used as the time applicable scope of tolerance, regard μ s order of magnitude as the circle on the whole. For example, can know, MCLK frequency division in guarding the gate dog’s time-recorder is 1/ 16 in proving from the device characteristic of S3C44BOX. Under the typical situation, MCLK =Shortest time unit t that the dog can distinguish that 60MHz, guards the gate =l/60 MHz/ 16 =0. 27μ s. Statistical error is about t/ 2, namely O. 1μ s order of magnitude. In case of that the time of μ’s s grade measure the precision, the relative error may be up to 1% – 10%; However, the occasion that this pair of a lot of speeds estimate can be accepted. If examined for time in above 10μ s, then there is not any question, can be quite accurate.
This kind of thinking can also be used for realizing that delay time accurately, because its timing does not depend on the execution time of order order will be influenced by systematic deployment,etc. when being carried out, therefore there are a lot of uncertainties ,And depend on the hardware frequency division to the master clock is counted.
Therefore the experiment is popularized, ARM disposes and guards the gate the dog can exist as the second clock in this kind of system. Demand, precise as to the intersection of μ and s, application that precision can’t satisfied with of RTC as to those times, this kind of treatment can yet be regarded as an accurate, high-efficient method.