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]

"Harmless" bugs in AT91 PIT code


New mailing list subscriber here, so please forgive me if I've muddled up the patch submission procedure...

The AT91 Periodic Interval Timer module has two "mostly harmless" bugs that the attached patch corrects. This patch is for:
.../packages/hal/arm/at91/var/current/src/timer_pit.c


First, in hal_clock_initialize(), "period" is stored directly in the PIT_MR register. It should be "(period - 1)". This error is corrected by the first call to hal_clock_reset(), but it still should be set up correctly the first time.

Second, there are four places where the PIV field in PIT_MR is masked with 0xffffff (24 bits), instead of 0xfffff (20 bits). This has no ill effect that I can see - except that the assert in hal_clock_reset() will not get triggered for certain illegal values.

--
Jim Seymour, Cipher Systems, Inc., 503-617-7447, http://www.cipher.com
Index: timer_pit.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/at91/var/current/src/timer_pit.c,v
retrieving revision 1.3
diff -b -u -r1.3 timer_pit.c
--- timer_pit.c	26 Mar 2006 11:02:59 -0000	1.3
+++ timer_pit.c	25 Jan 2007 01:03:50 -0000
@@ -66,7 +66,7 @@
   
   /* Set Period Interval timer and enable interrupt */
   HAL_WRITE_UINT32((AT91_PITC + AT91_PITC_PIMR), 
-                   period |  
+                   (period - 1) |
                    AT91_PITC_PIMR_PITEN |
                    AT91_PITC_PIMR_PITIEN);
   
@@ -81,11 +81,11 @@
   cyg_uint32 reg;
   cyg_uint32 pimr;
   
-  CYG_ASSERT(period < 0xffffff, "Invalid HAL clock configuration");
+  CYG_ASSERT(period < 0xfffff, "Invalid HAL clock configuration");
   
   // Check that the PIT has the right period.
   HAL_READ_UINT32((AT91_PITC + AT91_PITC_PIMR), pimr);
-  if ((pimr & 0xffffff) != (period - 1)){
+  if ((pimr & 0xfffff) != (period - 1)){
     HAL_WRITE_UINT32((AT91_PITC + AT91_PITC_PIMR), 
                      (period - 1) |  
                      AT91_PITC_PIMR_PITEN |
@@ -109,7 +109,7 @@
   HAL_READ_UINT32((AT91_PITC + AT91_PITC_PIMR),pimr);
   if (!(pimr & AT91_PITC_PIMR_PITEN)) {
     HAL_WRITE_UINT32((AT91_PITC + AT91_PITC_PIMR), 
-                     0xffffff | AT91_PITC_PIMR_PITEN);
+                     0xfffff | AT91_PITC_PIMR_PITEN);
   }
   
   HAL_READ_UINT32(AT91_PITC + AT91_PITC_PIIR, ir);
@@ -135,7 +135,7 @@
   
   // Calculate the wrap around period. 
   HAL_READ_UINT32(AT91_PITC + AT91_PITC_PIMR, piv);
-  piv = (piv & 0xffffff) - 1; 
+  piv = (piv & 0xfffff) - 1;
   
   hal_clock_read(&val1);
   while (ticks > 0) {

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