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]

cortexm fix rtc


This patch fixes a small issue with the SysTick reload value (this has to be period - 1) and fixed wrap-around in the hal_delay_us() function.

Simon
diff -r 88090cc51393 packages/hal/cortexm/arch/current/ChangeLog
--- a/packages/hal/cortexm/arch/current/ChangeLog	Tue Nov 04 13:57:25 2008 +0100
+++ b/packages/hal/cortexm/arch/current/ChangeLog	Tue Nov 04 16:51:48 2008 +0100
@@ -1,3 +1,9 @@
+2008-11-04  Simon Kallweit  <simon.kallweit@intefo.ch>
+	* include/hal_intr.h:
+	Fixed load value of SysTick counter.
+	* src/hal_misc.c:
+	Fixed wrap-around in hal_delay_us().
+
 2008-11-04  Simon Kallweit  <simon.kallweit@intefo.ch>
 
 	* include/hal_intr.h:
diff -r 88090cc51393 packages/hal/cortexm/arch/current/include/hal_intr.h
--- a/packages/hal/cortexm/arch/current/include/hal_intr.h	Tue Nov 04 13:57:25 2008 +0100
+++ b/packages/hal/cortexm/arch/current/include/hal_intr.h	Tue Nov 04 16:51:48 2008 +0100
@@ -326,7 +326,7 @@
 #define HAL_CLOCK_INITIALIZE( __period )                                \
 {                                                                       \
     cyg_uint32 __p = __period;                                          \
-    __p = hal_cortexm_systick_clock / ( 1000000 / __p );                \
+    __p = hal_cortexm_systick_clock / ( 1000000 / __p ) - 1;            \
     HAL_WRITE_UINT32(CYGARC_REG_SYSTICK_BASE+CYGARC_REG_SYSTICK_RELOAD, \
                      __p );                                             \
     HAL_WRITE_UINT32(CYGARC_REG_SYSTICK_BASE+CYGARC_REG_SYSTICK_CSR,    \
@@ -345,8 +345,8 @@
     cyg_uint32 __period, __value;                                       \
     HAL_READ_UINT32(CYGARC_REG_SYSTICK_BASE+CYGARC_REG_SYSTICK_RELOAD, __period ); \
     HAL_READ_UINT32(CYGARC_REG_SYSTICK_BASE+CYGARC_REG_SYSTICK_VALUE, __value ); \
-    __value = __period - __value;                                       \
-    __value /= (hal_cortexm_systick_clock/ 1000000 );                   \
+    __value = ( __period + 1 ) - __value;                               \
+    __value /= (hal_cortexm_systick_clock / 1000000 );                  \
     *(__pvalue) = __value;                                              \
 }
 
diff -r 88090cc51393 packages/hal/cortexm/arch/current/src/hal_misc.c
--- a/packages/hal/cortexm/arch/current/src/hal_misc.c	Tue Nov 04 13:57:25 2008 +0100
+++ b/packages/hal/cortexm/arch/current/src/hal_misc.c	Tue Nov 04 16:51:48 2008 +0100
@@ -500,8 +500,9 @@
     {
         HAL_CLOCK_READ( &t1 );
         if( t1 < t0 )
-            t1 += CYGNUM_HAL_RTC_PERIOD;
-        us -= t1-t0;
+            us -= (t1 + CYGNUM_HAL_RTC_PERIOD - t0);
+        else
+        	us -= t1 - t0;
         t0 = t1;
     }
 }

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