public inbox for ecos-patches@sourceware.org
 help / color / mirror / Atom feed
* cortexm fix rtc
@ 2008-11-04 15:54 simon.kallweit
  2008-11-04 18:23 ` Nick Garnett
  0 siblings, 1 reply; 4+ messages in thread
From: simon.kallweit @ 2008-11-04 15:54 UTC (permalink / raw)
  To: ecos-patches

[-- Attachment #1: Type: text/plain, Size: 151 bytes --]

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

[-- Attachment #2: cortexm_fix_rtc.patch --]
[-- Type: text/x-diff, Size: 2533 bytes --]

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;
     }
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-11-05 10:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-04 15:54 cortexm fix rtc simon.kallweit
2008-11-04 18:23 ` Nick Garnett
2008-11-04 18:53   ` Simon Kallweit
2008-11-05 10:02     ` Nick Garnett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).