summaryrefslogtreecommitdiff
path: root/cesar/cl/src
diff options
context:
space:
mode:
authormercadie2009-09-14 09:59:11 +0000
committermercadie2009-09-14 09:59:11 +0000
commit84c838bdafde5ff1910e90f03b7ca5dc9ddfaa19 (patch)
tree01cb2fada0c73944b55fd74795ef1d9bcfa057ba /cesar/cl/src
parentee49ffa9292465e9865355866453d04c6318e044 (diff)
* modify the way period_rtc is calculated
- calculate the period in a way that keeps maximum precision whatever resolution values are. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5537 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cl/src')
-rw-r--r--cesar/cl/src/data_rate.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/cesar/cl/src/data_rate.c b/cesar/cl/src/data_rate.c
index d9661b161a..fb058f3b37 100644
--- a/cesar/cl/src/data_rate.c
+++ b/cesar/cl/src/data_rate.c
@@ -39,9 +39,12 @@ data_rate_update_info (cl_data_rate_t *p_dr, uint data_size)
{
/* evaluate the periods phy tick counts only once for all */
#if defined (ECOS) && ECOS
+ /* period_rtc is calculated on a u64 to avoid overflow and keep
+ * maximum precision when the division is done.
+ */
cyg_resolution_t res =
cyg_clock_get_resolution (cyg_real_time_clock ());
- period_rtc = div(period_ns, div (res.dividend, res.divisor));
+ period_rtc = (u32) div((u64)period_ns * res.divisor, res.dividend);
#else
period_rtc = 1000;
#endif