<?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>App Timer tutorial, nrf_drv_clock_lfclk_request</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12983/app-timer-tutorial-nrf_drv_clock_lfclk_request</link><description>I am debugging a small program for the nRF52, which uses the App Timer and communicates over UART. I am trying to keep up with bug fixes, and so I&amp;#39;m using SDK 11.0. 
 The UART works fine, my program prints a greeting in the first few lines of main()</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 11 Apr 2016 07:33:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12983/app-timer-tutorial-nrf_drv_clock_lfclk_request" /><item><title>RE: App Timer tutorial, nrf_drv_clock_lfclk_request</title><link>https://devzone.nordicsemi.com/thread/49485?ContentTypeID=1</link><pubDate>Mon, 11 Apr 2016 07:33:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38ec208c-c8ab-4542-a919-2142be5a1465</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;I see your point :) This should be more visible. I will see if i can make some updates to &lt;a href="http://developer.nordicsemi.com/"&gt;developer.nordicsemi.com/&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer tutorial, nrf_drv_clock_lfclk_request</title><link>https://devzone.nordicsemi.com/thread/49484?ContentTypeID=1</link><pubDate>Fri, 08 Apr 2016 19:57:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df55ca80-590e-4292-ad70-721c83b482c1</guid><dc:creator>Ladasky</dc:creator><description>&lt;p&gt;Whoops.  That could very well be the source of my problems, as well as a few other software bugs I haven&amp;#39;t discussed in this thread.  Thanks for the information.  Somehow I only managed to see the message &amp;quot; we fixed a lot of bugs, so upgrade to the latest SDK,&amp;quot; and not the message &amp;quot;except when you can&amp;#39;t.&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer tutorial, nrf_drv_clock_lfclk_request</title><link>https://devzone.nordicsemi.com/thread/49483?ContentTypeID=1</link><pubDate>Fri, 08 Apr 2016 07:53:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce1d32e1-50f8-4205-8acb-aa156afe5608</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Hey. The PCA 10036 is not supported by the newest SDK and softdevices. You can see the compatibility matrix &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52/dita/nrf52/compatibility_matrix/ic_rev_sdk_sd_comp_matrix.html"&gt;here&lt;/a&gt;. Your card has the Engineering A chip on it. Can you try with the supported SDK and Softdevice?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer tutorial, nrf_drv_clock_lfclk_request</title><link>https://devzone.nordicsemi.com/thread/49482?ContentTypeID=1</link><pubDate>Thu, 07 Apr 2016 19:55:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b99b1e7-c9b9-4507-bcdd-90fd3b762313</guid><dc:creator>Ladasky</dc:creator><description>&lt;p&gt;Hello again Anders,  thanks for staying with me.  I am using the nRF52 Preview Kit, PCA10036.  My development environment is pure Linux, using GCC with the ARM toolchain.&lt;/p&gt;
&lt;p&gt;My code has every single line that the example you posted has, it&amp;#39;s just organized a little differently.  It still doesn&amp;#39;t print the periodic message I want.  I will try to copy your example and see what I get.&lt;/p&gt;
&lt;p&gt;I am working on several other programs for the PCA10036. I&amp;#39;ve noticed that the Makefiles changed between SDK 9.1 and SDK 11.  There are a lot more compiler flag settings in the most recent version.  I&amp;#39;m not sure what they all do.  Perhaps my CFLAGS in the Makefile require some changes.  Where are all of the CFLAGS settings documented?  There are so many.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer tutorial, nrf_drv_clock_lfclk_request</title><link>https://devzone.nordicsemi.com/thread/49481?ContentTypeID=1</link><pubDate>Thu, 07 Apr 2016 12:08:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c44f4592-d7cc-4821-8851-51a829e8802d</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Are you using the nRF52 Development kit, or a custom board? If DK, which version?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer tutorial, nrf_drv_clock_lfclk_request</title><link>https://devzone.nordicsemi.com/thread/49477?ContentTypeID=1</link><pubDate>Thu, 07 Apr 2016 11:48:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4639281-9986-4b97-863b-06373b86541c</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;app_timer uses SWI0 to send timer interrupts to the application timer handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer tutorial, nrf_drv_clock_lfclk_request</title><link>https://devzone.nordicsemi.com/thread/49480?ContentTypeID=1</link><pubDate>Tue, 05 Apr 2016 19:41:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2d6967d-c8f5-40b6-88c0-a59c6e1feb4a</guid><dc:creator>Ladasky</dc:creator><description>&lt;p&gt;Thanks for your reply, Anders.  I thought that the purpose of the App Timer was to provide a higher-level interface than the RTC, and to make using multiple timers easy (I will eventually need two)?  Does my App Timer code still need to reference the lower-level RTC functions?&lt;/p&gt;
&lt;p&gt;In any case: the lfclk_config() in the SDK11 RTC example reads thus:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ret_code_t err_code = nrf_drv_clock_init();
APP_ERROR_CHECK(err_code);
nrf_drv_clock_lfclk_request(NULL);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My own code is nearly identical, the only difference is that I declare err_code on an earlier line.  The App Timer tutorial shows nrf_drv_clock_lfclk_request being called with no arguments.  Consistent with the SDK11 docs, that doesn&amp;#39;t work for me.  I get a compiler error because nrf_drv_clock_lfclk_request wants a pointer to a nrf_drv_clock_handler_item_t (NULL, or false, substitutes when you don&amp;#39;t need a callback function).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer tutorial, nrf_drv_clock_lfclk_request</title><link>https://devzone.nordicsemi.com/thread/49479?ContentTypeID=1</link><pubDate>Tue, 05 Apr 2016 14:53:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7922837b-4042-4647-b593-4761228c0ab3</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Hey.&lt;/p&gt;
&lt;p&gt;Documentation of the clock driver is found &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk52.v0.9.0/group__nrf__clock__drv.html?resultof=%22%6e%72%66%5f%64%72%76%5f%63%6c%6f%63%6b%5f%6c%66%63%6c%6b%5f%72%65%71%75%65%73%74%22%20"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v11.0.0/rtc_example.html?cp=4_0_0_4_5_23"&gt;rtc example&lt;/a&gt; shows how to set up the rtc, as referenced by the APP_TIMER_INIT &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v10.0.0/group__app__timer.html?resultof=%22%61%70%70%5f%74%69%6d%65%72%22%20"&gt;documentation&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This module assumes that the LFCLK is
already running. If it is not, the
module will be non-functional, since
the RTC will not run. If you do not
use a SoftDevice, you must start the
LFCLK manually. See the rtc_example&amp;#39;s
lfclk_config() function for an example
of how to do this. If you use a
SoftDevice, the LFCLK is started on
SoftDevice init.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Let me know if you need some code snippets&lt;/p&gt;
&lt;p&gt;-Anders&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE 7 April. Trying it out on PCA10040 (nRF52 DK)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I did the following, which let me print something periodically with a app_timer. It was compiled with Keil 5. I am not sure if this will help you or not, but at least we know that this works with the Keil compiler.&lt;/p&gt;
&lt;p&gt;1: Start with the example project &amp;quot;uart&amp;quot; found in &amp;quot;nRF5_SDK_11\examples\peripheral&amp;quot;.&lt;/p&gt;
&lt;p&gt;2: include app_timer and clock headers. (and add the files to the include paths)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;quot;app_timer.h&amp;quot;
#include &amp;quot;nrf_drv_clock.h&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;3: define some timer variables&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define APP_TIMER_PRESCALER             0                                           /**&amp;lt; Value of the RTC1 PRESCALER register. */
#define APP_TIMER_OP_QUEUE_SIZE         4 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;4: Add the .c files to Keil (right click -&amp;gt;add existing files)&lt;/p&gt;
&lt;p&gt;5: Create a timer id&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;APP_TIMER_DEF(periodic_print_id);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;6: Create clock setup and timer handler&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void periodic_print(void * p_context){
    printf(&amp;quot;\n Periodic print: \n\r&amp;quot;);
}

static void lfclk_config(void)
{
    ret_code_t err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK(err_code);

    nrf_drv_clock_lfclk_request(NULL);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;7: Edit main to initialize and start the timer task.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    lfclk_config();
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    err_code = app_timer_create(&amp;amp;periodic_print_id, APP_TIMER_MODE_REPEATED, periodic_print);
    APP_ERROR_CHECK(err_code);
    err_code = app_timer_start(periodic_print_id, APP_TIMER_TICKS(500, APP_TIMER_PRESCALER),NULL);
    APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer tutorial, nrf_drv_clock_lfclk_request</title><link>https://devzone.nordicsemi.com/thread/49478?ContentTypeID=1</link><pubDate>Mon, 04 Apr 2016 22:24:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a9de7f9-3e40-4bda-92d9-ff0dc383bdb3</guid><dc:creator>Ladasky</dc:creator><description>&lt;p&gt;Following up to myself:  I just discovered the function nrf_drv_clock_lfclk_is_running().  After executing this...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = nrf_drv_clock_init();
APP_ERROR_CHECK(err_code);
nrf_drv_clock_lfclk_request(false);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;...nrf_drv_clock_lfclk_is_running() returns FALSE.  I have confirmed that I&amp;#39;m not starting LFCLK.  From my reading, I think that nrf_drv_config.h and the Makefile may also affect the hardware.  The App Timer tutorial says that App Timer uses RTC1.  I have modified my nrf_drv_config.h to read:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define RTC1_ENABLED 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When RTC1 triggers, which software interrupt does it use?  It might use SWI0, since the Makefile that comes with the App Time tutorial does not include the line:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;CFLAGS += -DSWI_DISABLE0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I made sure that my Makefile also does not include this line.  Any clues?  Thanks again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>