<?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>freeRTOS tick (LFCLK?) goes nuts after bootloader DFU</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49810/freertos-tick-lfclk-goes-nuts-after-bootloader-dfu</link><description>Hi, 
 
 We have developed a wearable device using the following config: nRF52832, SDK14.2, freertos based app, SD5.0.0 and secure_dfu_bootloader 
 Our device is headless hence we use &amp;#39;buttonless dfu&amp;#39; method 
 
 Everything works well including app OTA</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 18 Jul 2019 12:06:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49810/freertos-tick-lfclk-goes-nuts-after-bootloader-dfu" /><item><title>RE: freeRTOS tick (LFCLK?) goes nuts after bootloader DFU</title><link>https://devzone.nordicsemi.com/thread/199263?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 12:06:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:102e73ce-d91d-4880-8f62-deb67a05cebb</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Thanks for sharing the root cause and the fix with the rest of the community.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll forward your findings and feedback internally.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: freeRTOS tick (LFCLK?) goes nuts after bootloader DFU</title><link>https://devzone.nordicsemi.com/thread/199231?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 11:12:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45b0b59a-387f-4a9c-a52a-43969b705fe3</guid><dc:creator>eyalasko</dc:creator><description>&lt;p&gt;OK, I&amp;#39;ve nailed the problem -&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;On top the addition in my prev. post, there&amp;nbsp;should be&amp;nbsp;a short delay to compensate for the HFCLK-LFCLK jitter (see &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Frtc.html&amp;amp;cp=3_1_0_24_7&amp;amp;anchor=concept_s4s_fg4_sr"&gt;here&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;For the sake of fellow developers attached is the&amp;nbsp;final modified code (+ #include &amp;quot;nrf_delay.h&amp;quot; at the beginning of the file):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void vPortSetupTimerInterrupt( void )
{
    /* Request LF clock */
    nrf_drv_clock_lfclk_request(NULL);

    /* Configure SysTick to interrupt at the requested rate. */
	nrf_rtc_task_trigger (portNRF_RTC_REG, NRF_RTC_TASK_STOP);	// &amp;lt;&amp;lt; Add these...
	nrf_delay_ms(1);	                                        // &amp;lt;&amp;lt; ...two lines
    nrf_rtc_prescaler_set(portNRF_RTC_REG, portNRF_RTC_PRESCALER);
    nrf_rtc_int_enable   (portNRF_RTC_REG, RTC_INTENSET_TICK_Msk);
    nrf_rtc_task_trigger (portNRF_RTC_REG, NRF_RTC_TASK_CLEAR);
    nrf_rtc_task_trigger (portNRF_RTC_REG, NRF_RTC_TASK_START);
    nrf_rtc_event_enable(portNRF_RTC_REG, RTC_EVTEN_OVRFLW_Msk);

    NVIC_SetPriority(portNRF_RTC_IRQn, configKERNEL_INTERRUPT_PRIORITY);
    NVIC_EnableIRQ(portNRF_RTC_IRQn);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Nordic fellows,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Consider adding this fix (after validation of course) to the next SDK version/patch&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Good luck&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: freeRTOS tick (LFCLK?) goes nuts after bootloader DFU</title><link>https://devzone.nordicsemi.com/thread/199195?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 09:29:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb222c83-b217-45a0-a32a-4c33ac15e527</guid><dc:creator>eyalasko</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tracked down the&amp;nbsp;root cause -&amp;nbsp;It is indeed a problem with the rtos tick clock source (RTC1).&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve added RTC1-&amp;gt;PRESCALER value printout in one of the tasks startup code.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;On normal system start, this value ix 0x1F as expected (dividing 32768Hz LFCLK by 32 = 1024Hz)&lt;/p&gt;
&lt;p&gt;On system start after BL DFU,&amp;nbsp;this value is 0 !! hence the x32 tick speed.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The nRF52832 datasheet mentions that the prescaler&amp;nbsp;has to be stopped before its value can be set, so I&amp;#39;ve added a call to stop the clock in the rtos tick initialization routine vPortSetupTimerInterrupt(), however it still does not solve the problem.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void vPortSetupTimerInterrupt( void )
{
    /* Request LF clock */
    nrf_drv_clock_lfclk_request(NULL);

    /* Configure SysTick to interrupt at the requested rate. */
	nrf_rtc_task_trigger (portNRF_RTC_REG, NRF_RTC_TASK_STOP);	// &amp;lt;&amp;lt; Added this line
    nrf_rtc_prescaler_set(portNRF_RTC_REG, portNRF_RTC_PRESCALER);
    nrf_rtc_int_enable   (portNRF_RTC_REG, RTC_INTENSET_TICK_Msk);
    nrf_rtc_task_trigger (portNRF_RTC_REG, NRF_RTC_TASK_CLEAR);
    nrf_rtc_task_trigger (portNRF_RTC_REG, NRF_RTC_TASK_START);
    nrf_rtc_event_enable(portNRF_RTC_REG, RTC_EVTEN_OVRFLW_Msk);

    NVIC_SetPriority(portNRF_RTC_IRQn, configKERNEL_INTERRUPT_PRIORITY);
    NVIC_EnableIRQ(portNRF_RTC_IRQn);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;On what circumstances does this register (RTC1-&amp;gt;PRESCALER) is zerod (other than hard reset)&lt;/p&gt;
&lt;p&gt;What can be the reason it is not being set as requested in&amp;nbsp;&lt;span&gt;vPortSetupTimerInterrupt() ?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: freeRTOS tick (LFCLK?) goes nuts after bootloader DFU</title><link>https://devzone.nordicsemi.com/thread/198595?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2019 06:49:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b35063cf-6cd0-47a6-9fab-2f5e3208cd00</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi. &lt;/p&gt;
&lt;p&gt;We are actually a little short on FreeRTOS and DFU expertise at the moment, due to summer vacation here in Norway. I&amp;#39;ll try to track down the root cause of this, but some delay in response time will be expected.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sorry for the inconvenience.&amp;nbsp;&lt;br /&gt;Best regards,&amp;nbsp;&lt;br /&gt;Joakim Jakobsen&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>