This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Initialisation for the AT91... PIT if there is no kernel...


Possible solultion but not tested yet:

void hal_delay_us(cyg_int32 usecs)
{
 cyg_int64 ticks;
 cyg_uint32 val1, val2;
 cyg_uint32 piv;

 // Calculate how many PIT ticks the required number of microseconds
 // equate to. We do this calculation in 64 bit arithmetic to avoid
 // overflow.
 ticks = (((cyg_uint64)usecs) *
          ((cyg_uint64)CYGNUM_HAL_ARM_AT91_CLOCK_SPEED))/16/1000000LL;

HAL_READ_UINT32(AT91_PITC + AT91_PITC_PIMR, piv);

piv = (piv & 0xffffff) -1; //periode

 hal_clock_read(&val1);
 while (ticks > 0) {
   hal_clock_read(&val2);
   if (val2 < val1)
     ticks -= ((piv + val2) - val1); //overflow occurred
   else
     ticks -= (val2 - val1);
   val1 = val2;
 }
}


Oliver Munz


----- Original Message ----- From: "Andrew Lunn" <andrew@lunn.ch>
To: "oliver munz @ s p e a g" <munz@speag.ch>
Cc: <ecos-patches@sourceware.org>
Sent: Thursday, March 23, 2006 9:03 PM
Subject: Re: Initialisation for the AT91... PIT if there is no kernel...



On Tue, Mar 21, 2006 at 11:49:38PM +0100, oliver munz @ s p e a g wrote:
This Patch fixes problems whit the AT91 PIT, if it should run whitout the
kernel.

This fixes the problem a different way.


Andrew



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]