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: hal/arm/at91/var/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/at91/var/current/ChangeLog,v
retrieving revision 1.32
diff -u -r1.32 ChangeLog
--- hal/arm/at91/var/current/ChangeLog  13 Mar 2006 07:47:23 -0000      1.32
+++ hal/arm/at91/var/current/ChangeLog  23 Mar 2006 20:00:24 -0000
@@ -1,3 +1,9 @@
+2006-03-23  Andrew Lunn  <[EMAIL PROTECTED]>
+
+       * src/timer_pit.c (hal_delay_us): Start the PIT if it is not
+       running when hal_delay_us is called. This happens when the kernel
+       is not used. Problem found by Oliver Munz.
+
 2006-03-10  Oliver Munz  <[EMAIL PROTECTED]>
 
        * src/hal_diag.c (cyg_hal_plf_serial_isr): Change the #ifdefs to
Index: hal/arm/at91/var/current/src/timer_pit.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/at91/var/current/src/timer_pit.c,v
retrieving revision 1.1
diff -u -r1.1 timer_pit.c
--- hal/arm/at91/var/current/src/timer_pit.c    19 Feb 2006 19:08:28 -0000      
1.1
+++ hal/arm/at91/var/current/src/timer_pit.c    23 Mar 2006 20:00:24 -0000
@@ -105,7 +105,14 @@
 {
   cyg_int64 ticks;
   cyg_uint32 val1, val2;
-  cyg_uint32 piv;
+  cyg_uint32 pimr;
+  
+  // Check that the PIT is running. If not start it.
+  HAL_READ_UINT32((AT91_PITC + AT91_PITC_PIMR),pimr);
+  if (!(pimr & AT91_PITC_PIMR_PITEN)) {
+    HAL_WRITE_UINT32((AT91_PITC + AT91_PITC_PIMR), 
+                     0xffff | AT91_PITC_PIMR_PITEN);
+  }
   
   // Calculate how many PIT ticks the required number of microseconds
   // equate to. We do this calculation in 64 bit arithmetic to avoid
@@ -118,8 +125,6 @@
   // why, please let me know!
   ticks = ticks / 3;
   
-  HAL_READ_UINT32(AT91_PITC + AT91_PITC_PIMR, piv);
-  
   while (ticks > 0) {
     hal_clock_read(&val1);
     do {

Reply via email to