From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28357 invoked by alias); 22 Jun 2005 07:26:50 -0000 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Received: (qmail 28281 invoked by uid 22791); 22 Jun 2005 07:26:30 -0000 Received: from asav1.lyse.net (HELO asav1.lyse.net) (213.167.96.68) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 22 Jun 2005 07:26:30 +0000 Received: from asav1.lyse.net (asav1.lyse.net [127.0.0.1]) by localhost.lyse.net (Postfix) with ESMTP id 59174902DA for ; Wed, 22 Jun 2005 09:21:29 +0200 (CEST) Received: from mail1.lyse.net (unknown [192.168.42.2])by asav1.lyse.net (Postfix) with ESMTP id 4774F90067for ; Wed, 22 Jun 2005 09:21:29 +0200 (CEST) Received: from [84.234.138.230] (helo=[192.168.0.193])by mail1.lyse.net with smtp (Exim 4.34)id 1Dkzbv-0001Fq-Bvfor ecos-discuss@sources.redhat.com; Wed, 22 Jun 2005 09:25:23 +0200 From: =?ISO-8859-1?Q?=D8yvind?= Harboe To: ecos-discuss@sources.redhat.com Content-Type: text/plain; charset=ISO-8859-1 Date: Wed, 22 Jun 2005 07:26:00 -0000 Message-Id: <1119425206.20805.21.camel@localhost.localdomain> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-imss-version: 2.028 X-imss-result: Passed X-imss-scores: Clean:6.05477 C:2 M:3 S:5 R:5 X-imss-settings: Baseline:2 C:1 M:1 S:1 R:1 (0.1500 0.1500) Subject: [ECOS] HAL_DELAY_US() default implementation X-SW-Source: 2005-06/txt/msg00197.txt.bz2 Ref http://ecos.sourceware.org/ml/ecos-patches/2005-06/msg00033.html Looks good. Thoughts on a default implementation: - Add calibration by default on startup. There are so many things affecting the performance: type of ram/flash, caches, off-frequency crystals(e.g. 64MHz instead of 66 MHz crystal), etc.=20 I'm not entirely convinced that the calibration number can be put in the source and committed to CVS. E.g. for the AT91 there are 5 HALs X 3 types of code memory(internal, external & flash) =3D 15 calibration numbers. The number of combinations for all the eCos HAL's could easy reach thousands. - Calibration can be disabled by specifying the number in=20 a CDL option. This number is extracted by running the app in=20 the debugger and setting a breakpoint at the end of the calibration=20 loop. - The calibration algorithm must have some sort of way to estimating the accuracy to determine when the calibration should terminate. Integer math. Some code: /* this fn takes at least 0.000001342194658704 seconds=20 * to execute one iteration (EB40a running out of flash). *=20 * A number of factors affect this number: *=20 * - Is the code in ram/rom, wait states * - Iterrupts/task switches can slow it down */ =20 static void busy(int j) { __asm volatile ( =09 ".L1: nop\n"=20 "sub %0,%0,#1\n"=20 "cmp %0,#0\n" "bne .L1\n" =09 : "+r" (j)); } /* times the busy() function */ void timeIt()=20 { for (int j=3D1000; j<10000000; j=3D((j*110)/100)) { // time it. cyg_tick_count_t lastTime=3Dcyg_current_time(); busy(j); cyg_tick_count_t current=3Dcyg_current_time(); diag_printf("%d %d\n", j, (int)(current-lastTime)); } } /* Waits at least this many us. *=20 * Does not require kernel to be running. */ void waitus(int us) { float oneIteration=3D0.000001342194658704; int iterations; iterations=3D(int)(us*1000000*oneIteration); busy(iterations); } Example run: loops ticks time/seconds 1395411 187 0,000001340106964901 1534952 206 0,000001342061510718 1688447 227 0,000001344430710588 1857291 249 0,000001340662287170 2043020 274 0,000001341151824260 2247322 301 0,000001339371928010 2472054 331 0,000001338967514464 2719259 365 0,000001342277436610 2991184 401 0,000001340606261601 3290302 441 0,000001340302501108 3619332 486 0,000001342789221879 3981265 535 0,000001343793995125 4379391 588 0,000001342652437291 4817330 647 0,000001343067632900 5299063 711 0,000001341746644643 5828969 782 0,000001341575156773 6411865 861 0,000001342823031988 7053051 947 0,000001342681344570 7758356 1042 0,000001343068041735 8534191 1145 0,000001341662027485 9387610 1260 0,000001342194658704 --=20 =D8yvind Harboe http://www.zylin.com -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss