From: "simon.kallweit@intefo.ch" <simon.kallweit@intefo.ch>
To: ecos-patches@ecos.sourceware.org
Subject: cortexm fix rtc
Date: Tue, 04 Nov 2008 15:54:00 -0000 [thread overview]
Message-ID: <49107011.7060704@intefo.ch> (raw)
[-- 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;
}
}
next reply other threads:[~2008-11-04 15:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-04 15:54 simon.kallweit [this message]
2008-11-04 18:23 ` Nick Garnett
2008-11-04 18:53 ` Simon Kallweit
2008-11-05 10:02 ` Nick Garnett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49107011.7060704@intefo.ch \
--to=simon.kallweit@intefo.ch \
--cc=ecos-patches@ecos.sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).