From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 22 Apr 2009 22:49:36 +0200 Subject: [U-Boot] U-Boot Timer Qualification Message-ID: <20090422204936.GB29252@game.jcrosoft.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi all, For all Timer modification a minimun of qualification is mandatory as it will impact a lots of part of u-boot. So for this purpose I'll propose you to use one of this two approche to report the precition of your timer or update 1) Clock generation Mesurement Tools needed: Scope or Frequency metter In this approch you will use a gpio to generate a 1Khz and at 1Mhz or it's maximun generated clock frequency before generate one of this clock you will need to known your GPIO and system latency. For this purpose you will generate a clock at your maximum speed as this algo set_gpio_as_output(gpio); while(1) { set_gpio_value(gpio, 1); set_gpio_value(gpio, 0); } after measure the clock (hg_clock) you will it's latency now you will try to generate the 1Khz clock to known the precision of your timer at 1ms while(1) { set_gpio_value(gpio, 1); udelay(1000); set_gpio_value(gpio, 0); } now measure the frequency of the clock the last step is now calculate your precision hg_clock = measured max speed generated clock ms_clock = measured 1Khz generated clock p = (1 / 1000 - (1 / hg_clock + 1 / ms_clock)) * 1000 depending on max generated clock you can known your precision as 1us or less 2) Watch mesurement measured with stop-watch on 100s delay x = measured time p = (100 - x) / 100 Best Regards, J.