<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Trying to use TIMER2 for FreeRTOS tick with SoftDevice running</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/10283/trying-to-use-timer2-for-freertos-tick-with-softdevice-running</link><description>Hi, 
 The established time tick source for FreeRTOS is RTC1 via the APP_TIMER module. I am trying to shift the basis of the APP_TIMER from RTC1 to TIMER2, so that I can use RTC1 to maintain calendar time. I intend to sleep the processor, waking on an</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 19 Nov 2015 19:24:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/10283/trying-to-use-timer2-for-freertos-tick-with-softdevice-running" /><item><title>RE: Trying to use TIMER2 for FreeRTOS tick with SoftDevice running</title><link>https://devzone.nordicsemi.com/thread/38159?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2015 19:24:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d94e7e52-45d4-4e6c-8cf8-dcc4a5abbeb2</guid><dc:creator>benkokes</dc:creator><description>&lt;p&gt;Yes, the processor in question is the nRF51822-QFAC. Once I get the tick to use something other than RTC1, we plan on using the tick-less feature going forward.&lt;/p&gt;
&lt;p&gt;Currently, we are using the tick as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void systick_timeout_handler (void * p_context)
{
    void xPortSysTickHandler (void);
    UNUSED_PARAMETER(p_context);
    tick_cnt++;
    xPortSysTickHandler ();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, first thing is first -- moving over to TIMER2.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to use TIMER2 for FreeRTOS tick with SoftDevice running</title><link>https://devzone.nordicsemi.com/thread/38156?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 10:59:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3f7d42f-bc4a-471f-b6b8-1ef8d0f05bea</guid><dc:creator>Pertti Kasanen</dc:creator><description>&lt;p&gt;I wrote an earlier port of FreeRTOS for the nRF51. I have not yet migrated our own code to use the SDK versio of the FreeRTOS yet.  I&amp;#39;m not 100% sure of this yet, but probably you can share the RTC1.&lt;/p&gt;
&lt;p&gt;There is no problem putting FreeRTOS into sleep on nRF51. It could be enough it you compile it with configUSE_TICKLESS_IDLE and configUSE_IDLE_HOOK enabled and add the following idle hook:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void vApplicationIdleHook( void ) {
    /*
       This signals the softdevice handler that we want the CPU to
       sleep until an event/interrupt occurs. During this time the
       softdevice will do what it needs to do; in our case: send
       adverts
    */

    uint32_t err_code = sd_app_evt_wait();
    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I&amp;#39;m interested in hearing your experiences.&lt;/p&gt;
&lt;p&gt;Pertti&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to use TIMER2 for FreeRTOS tick with SoftDevice running</title><link>https://devzone.nordicsemi.com/thread/38158?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 10:51:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6a4546f-50f1-4827-b696-86bd81a922ba</guid><dc:creator>Pertti Kasanen</dc:creator><description>&lt;p&gt;nFR51 is a Cortex-M0 device but without the SysTick feature. nRF52 has Systick.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to use TIMER2 for FreeRTOS tick with SoftDevice running</title><link>https://devzone.nordicsemi.com/thread/38157?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2015 17:32:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28d434b7-3e65-4b32-a6e2-1e705dafa2e8</guid><dc:creator>www.FreeRTOS.org</dc:creator><description>&lt;p&gt;Is this an ARM Cortex-M device?  If so, then the generic port uses the SysTick timer to generate the tick interrupt by default - but the timer functions are weak symbols, allowing them to be overridden by application code - which seems to be the case here if RTC1 is being used.  If RTC1 is a low power timer, then I suspect it is being used so the FreeRTOS&amp;#39;s low power tick-less features can be used to greater effect than when using SysTick.&lt;/p&gt;
&lt;p&gt;If you are not using the tick-less features then it is a matter of&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Writing code that generates an interrupt at the desired frequency.  Call the function that sets up the interrupt vPortSetupTimerInterrupt(), so it replaces the default function of that name.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install the FreeRTOS tick interrupt handler as the handler for the interrupt.  The easiest way of doing that is to install xPortSysTickHandler() systick handler and the handler - xPortSysTickHandler() is defined in the FreeRTOS/Source/portable/[compiler]/[architecture]/port.c file used by your build.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you are using the tick-less features then it is a bit more complex, as you need to reprogram the timer before and after going to sleep.  I suggest you use whatever is currently provided to you as a reference, along with &lt;a href="http://www.freertos.org/low-power-tickless-rtos.html"&gt;www.freertos.org/low-power-tickless-rtos.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>