<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p><br>
</p>
<meta content="text/html; charset=UTF-8">
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>I've pasted my program below.</p>
<p><br>
I don't think I'm having issues printing the output, since I only print once a second. But I'm seeing the max period between the timer firing go as high as 3000 microseconds.</p>
<p><br>
</p>
<p>Thanks,<br>
</p>
<p>Janet</p>
<p><br>
</p>
<p>*******************</p>
<p><br>
</p>
<p></p>
<div>#include <bsp.h></div>
<div>#include "../../testmacros.h"</div>
<div><br>
</div>
<div>#include <assert.h></div>
<div>#include <stdio.h></div>
<div>#include <stdlib.h></div>
<div>#include <limits.h></div>
<div><br>
</div>
<div>// Timer statistics</div>
<div>volatile uint64_t g_prevUpTimeUsec;</div>
<div>volatile uint64_t g_totalProcessingPeriodUsec;</div>
<div>volatile uint64_t g_maxProcessingDeltaUsec;</div>
<div>volatile uint64_t g_minProcessingDeltaUsec;</div>
<div>volatile uint32_t g_numTimerIntervals;</div>
<div>static const uint32_t kNumTimerIntervals=1000;</div>
<div><br>
</div>
<div>rtems_id main_task;</div>
<div><br>
</div>
<div>rtems_timer_service_routine test_timer(</div>
<div> rtems_id timer,</div>
<div> void *arg</div>
<div>)</div>
<div>{</div>
<div> // restart the timer</div>
<div> (void)rtems_timer_reset(timer);</div>
<div><br>
</div>
<div> uint64_t currUpTimeUsec;</div>
<div> uint64_t processingDeltaUsec;</div>
<div><br>
</div>
<div> currUpTimeUsec = rtems_clock_get_uptime_nanoseconds() / 1000;</div>
<div> assert (currUpTimeUsec > g_prevUpTimeUsec);</div>
<div> processingDeltaUsec = currUpTimeUsec - g_prevUpTimeUsec;</div>
<div> g_totalProcessingPeriodUsec += processingDeltaUsec;</div>
<div> assert(g_totalProcessingPeriodUsec > 0);</div>
<div> g_numTimerIntervals++;</div>
<div> g_prevUpTimeUsec = currUpTimeUsec;</div>
<div> if (processingDeltaUsec > g_maxProcessingDeltaUsec) {</div>
<div> g_maxProcessingDeltaUsec = processingDeltaUsec;</div>
<div> }</div>
<div> if (processingDeltaUsec < g_minProcessingDeltaUsec) {</div>
<div> g_minProcessingDeltaUsec = processingDeltaUsec;</div>
<div> }</div>
<div> if (g_numTimerIntervals == kNumTimerIntervals) {</div>
<div> uint64_t avgProcessingPeriodUsec;</div>
<div><br>
</div>
<div> avgProcessingPeriodUsec = (g_totalProcessingPeriodUsec /</div>
<div> g_numTimerIntervals);</div>
<div><br>
</div>
<div> printk("total %d\n",(int)g_totalProcessingPeriodUsec);</div>
<div> printk("avg %d\n",(int)avgProcessingPeriodUsec);</div>
<div> printk("min %d\n",(int)g_minProcessingDeltaUsec);</div>
<div> printk("max %d\n",(int)g_maxProcessingDeltaUsec);</div>
<div><br>
</div>
<div> g_totalProcessingPeriodUsec = 0;</div>
<div> g_maxProcessingDeltaUsec = 0;</div>
<div> g_minProcessingDeltaUsec = 0xffffffffffffffff;</div>
<div> g_numTimerIntervals = 0;</div>
<div> }</div>
<div>}</div>
<div><br>
</div>
<div>rtems_task Init(</div>
<div> rtems_task_argument argument</div>
<div>)</div>
<div>{</div>
<div> rtems_status_code status;</div>
<div> rtems_id timer;</div>
<div> </div>
<div> puts( "\n\n*** 1kHz TIMER TEST START ***" );</div>
<div><br>
</div>
<div> main_task = rtems_task_self();</div>
<div><br>
</div>
<div></div>
<div> status = rtems_timer_create( 1, &timer );</div>
<div> assert( status == RTEMS_SUCCESSFUL );</div>
<div><br>
</div>
<div> // Set up timer</div>
<div> rtems_interval timer_ticks;</div>
<div> timer_ticks = (rtems_clock_get_ticks_per_second() / 1000);</div>
<div> assert (timer_ticks == 2); // 500 usec per "tick"</div>
<div><br>
</div>
<div> // Set timer globals</div>
<div> g_prevUpTimeUsec = rtems_clock_get_uptime_nanoseconds() / 1000;</div>
<div> assert (g_prevUpTimeUsec > 0);</div>
<div> g_totalProcessingPeriodUsec = 0;</div>
<div> g_maxProcessingDeltaUsec = 0;</div>
<div> g_minProcessingDeltaUsec = 0xffffffffffffffff;</div>
<div> g_numTimerIntervals = 0;</div>
<div><br>
</div>
<div> status = rtems_timer_fire_after(timer, timer_ticks, test_timer, NULL);</div>
<div> assert( status == RTEMS_SUCCESSFUL );</div>
<div><br>
</div>
<div> int i;</div>
<div> for(i = 0; i < 60; i++) { // Run for 2 min...</div>
<div> rtems_task_wake_after(timer_ticks * 1000);</div>
<div> }</div>
<div><br>
</div>
<div> rtems_timer_cancel(timer);</div>
<div> rtems_task_wake_after(timer_ticks * 1000);</div>
<div><br>
</div>
<div> puts("*** 1kHz TIMER TEST END ***\n\n");</div>
<div> exit( 0 );</div>
<div>}</div>
<div><br>
</div>
<div>/* configuration information */</div>
<div>#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER</div>
<div>#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER</div>
<div><br>
</div>
<div>#define CONFIGURE_MICROSECONDS_PER_TICK 500</div>
<div><br>
</div>
<div>#define CONFIGURE_RTEMS_INIT_TASKS_TABLE</div>
<div><br>
</div>
<div>#define CONFIGURE_MAXIMUM_TASKS 1</div>
<div>#define CONFIGURE_MAXIMUM_TIMERS 1</div>
<div><br>
</div>
<div>#define CONFIGURE_INIT</div>
<div>#include <rtems/confdefs.h></div>
<br>
<p></p>
<p><br>
</p>
</div>
<hr tabindex="-1" disabled="true" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Sebastian Huber <sebastian.huber@embedded-brains.de><br>
<b>Sent:</b> Wednesday, December 7, 2016 10:52:59 PM<br>
<b>To:</b> RTEMS<br>
<b>Cc:</b> Janet Schneider<br>
<b>Subject:</b> Re: 1kHz timer behavior on Cyclone V</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt">
<div class="PlainText">Hello Janet,<br>
<br>
could you send your test program to the list? How do you report the <br>
timestamps? Via a serial line?<br>
<br>
-- <br>
Sebastian Huber, embedded brains GmbH<br>
<br>
Address : Dornierstr. 4, D-82178 Puchheim, Germany<br>
Phone : +49 89 189 47 41-16<br>
Fax : +49 89 189 47 41-09<br>
E-Mail : sebastian.huber@embedded-brains.de<br>
PGP : Public key available on request.<br>
<br>
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<br>
<br>
</div>
</span></font></div>
</body>
</html>