ppc40x hal_delay_us patch

Gary Thomas gary@mlbassoc.com
Thu May 19 13:29:00 GMT 2005


On Wed, 2005-05-18 at 20:48 +0200, Peter Korsgaard wrote:
> Hi,
> 
> The following little patch removes a double initialization in
> hal_ppc40x_delay_us and makes it work correctly if system clock is
> different than 100 Hz.

I like it this way better - the calculations will end up exactly
the same as before and the way it's written tells you why it's
being done this way:

  delay_period = ((_period / ((CYGNUM_HAL_RTC_NUMERATOR/1000) / CYGNUM_HAL_RTC_DENOMINATOR)) * us);

  _period = timer value for system clock (represented in ns)
  (CYGNUM_HAL_RTC_NUMERATOR/1000) = scale to us (raw value is ns)

  _period/CLOCK_CALCULATION = timer value for 1 us

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------



More information about the Ecos-patches mailing list