<?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>lfclk, rtc issue on SDK13</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23652/lfclk-rtc-issue-on-sdk13</link><description>I am trying to set up RTC2 by following an example
 github.com/.../saadc_low_power 
I ported it to my project which is running a softdevice on nRF52. It works perfectly fine on SDK11 but has problems on SDK13.0 / 13.1.
Seems like nrf_drv_clock_init</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 07 Nov 2017 10:40:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23652/lfclk-rtc-issue-on-sdk13" /><item><title>RE: lfclk, rtc issue on SDK13</title><link>https://devzone.nordicsemi.com/thread/92971?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2017 10:40:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65c88ab3-3714-4a13-8ab5-f465e47f2eec</guid><dc:creator>pirm</dc:creator><description>&lt;p&gt;Thank you for your answer.
While trying to purge my code to send the project, I found my mistake:
I was declaring an instance of the RTC that was different from wich declared in sdk_config.h :
const nrf_drv_rtc_t rtc = NRF_DRV_RTC_INSTANCE(0); /**&amp;lt; Declaring an instance of nrf_drv_rtc for RTC0. */&lt;/p&gt;
&lt;p&gt;I change to RTC2 and it works. It was an heritage from previous work with SDK11 and nRF51822 board.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lfclk, rtc issue on SDK13</title><link>https://devzone.nordicsemi.com/thread/92972?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2017 11:24:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:975997c4-a1d1-4bdc-8d13-5c66e35ab123</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Error 4097 (0x1001) corresponds to &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/group__nrf__sdm__error.html#ga5e01566a9b1b0f6fdec349198401e5bd"&gt;&lt;code&gt;NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION&lt;/code&gt;&lt;/a&gt;. The second error (INVALID MEMORY ACCESS) indicates that the function is accessing a peripheral &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/sd_resource_reqs/hw_block_interrupt_vector.html?cp=2_3_1_0_6_0"&gt;restricted or blocked by the softdevice&lt;/a&gt;, without using the softdevice API. Can you upload the project for review of the code and debugging?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lfclk, rtc issue on SDK13</title><link>https://devzone.nordicsemi.com/thread/92970?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 16:49:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2605a082-c77c-46c0-a546-035acab00998</guid><dc:creator>pirm</dc:creator><description>&lt;p&gt;I have the same problem with SDK 14.1.
If I initialize CLOCK and RTC driver before BLE stack I have an error in return of nrf_sdh_enable_request():&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;error&amp;gt; app: ERROR 4097 [Unknown error code] 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If I initialize BLE stack first, I can initialize CLOCK (nrf_drv_clock_init()) but RTC initialization fails (nrf_drv_rtc_init()) with the error:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;error&amp;gt; app: SOFTDEVICE: INVALID MEMORY ACCESS
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;RTC section of sdk_config.h:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// &amp;lt;e&amp;gt; RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver
//==========================================================
#ifndef RTC_ENABLED
#define RTC_ENABLED 1
#endif
// &amp;lt;o&amp;gt; RTC_DEFAULT_CONFIG_FREQUENCY - Frequency  &amp;lt;16-32768&amp;gt; 


#ifndef RTC_DEFAULT_CONFIG_FREQUENCY
#define RTC_DEFAULT_CONFIG_FREQUENCY 32768
#endif

// &amp;lt;q&amp;gt; RTC_DEFAULT_CONFIG_RELIABLE  - Ensures safe compare event triggering
 

#ifndef RTC_DEFAULT_CONFIG_RELIABLE
#define RTC_DEFAULT_CONFIG_RELIABLE 0
#endif

// &amp;lt;o&amp;gt; RTC_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
 

// &amp;lt;i&amp;gt; Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
// &amp;lt;0=&amp;gt; 0 (highest) 
// &amp;lt;1=&amp;gt; 1 
// &amp;lt;2=&amp;gt; 2 
// &amp;lt;3=&amp;gt; 3 
// &amp;lt;4=&amp;gt; 4 
// &amp;lt;5=&amp;gt; 5 
// &amp;lt;6=&amp;gt; 6 
// &amp;lt;7=&amp;gt; 7 

#ifndef RTC_DEFAULT_CONFIG_IRQ_PRIORITY
#define RTC_DEFAULT_CONFIG_IRQ_PRIORITY 7
#endif

// &amp;lt;q&amp;gt; RTC0_ENABLED  - Enable RTC0 instance
 

#ifndef RTC0_ENABLED
#define RTC0_ENABLED 0
#endif

// &amp;lt;q&amp;gt; RTC1_ENABLED  - Enable RTC1 instance
 

#ifndef RTC1_ENABLED
#define RTC1_ENABLED 0
#endif

// &amp;lt;q&amp;gt; RTC2_ENABLED  - Enable RTC2 instance
 

#ifndef RTC2_ENABLED
#define RTC2_ENABLED 1
#endif

// &amp;lt;o&amp;gt; NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt 
#ifndef NRF_MAXIMUM_LATENCY_US
#define NRF_MAXIMUM_LATENCY_US 2000
#endif
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lfclk, rtc issue on SDK13</title><link>https://devzone.nordicsemi.com/thread/92969?ContentTypeID=1</link><pubDate>Tue, 01 Aug 2017 22:02:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d91839d9-5cc3-4853-91d3-2f7116ba0f30</guid><dc:creator>fteng</dc:creator><description>&lt;p&gt;After some debugging I come to the conclusion there is a condition check in sd_softdevice_enable on lfclk that does not allow lfclk to be enabled outside of softdevice. It raises an exception if so.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lfclk, rtc issue on SDK13</title><link>https://devzone.nordicsemi.com/thread/92968?ContentTypeID=1</link><pubDate>Fri, 28 Jul 2017 08:41:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dec0a259-b701-416c-b6cf-37a9a31ea3f0</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can&amp;#39;t call &lt;code&gt;nrf_drv_rtc_init()&lt;/code&gt; with &lt;code&gt;p_config = NULL&lt;/code&gt;. There is an assert inside the function that checks if &lt;code&gt;p_config&lt;/code&gt; is set, but this is not firing for some reason. If called without config, the priority will not be set to one of the allowed levels for use with softdevice.&lt;/p&gt;
&lt;p&gt;You should get default config from &lt;em&gt;sdk_config.h&lt;/em&gt; like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void rtc_config(void)
{
    uint32_t err_code;

    //Initialize RTC instance
    nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG;
    err_code = nrf_drv_rtc_init(&amp;amp;rtc, &amp;amp;config, rtc_handler);
    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lfclk, rtc issue on SDK13</title><link>https://devzone.nordicsemi.com/thread/92966?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2017 22:47:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9733c56a-3ad2-413f-b157-fa5d4d98e332</guid><dc:creator>fteng</dc:creator><description>&lt;p&gt;const  nrf_drv_rtc_t           rtc = NRF_DRV_RTC_INSTANCE(2);
sdk_config.h probably too large to upload. I just change the followings in a ble_app_hrs or ble_app_hts example. everything else stays the same except lfclk_config(), rtc_config(void) added.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define CLOCK_ENABLED 1
#define RTC_ENABLED 1
#define RTC2_ENABLED 1
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lfclk, rtc issue on SDK13</title><link>https://devzone.nordicsemi.com/thread/92967?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2017 08:13:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5ccda0c-952b-4ef9-bf8b-cd186c40a1d2</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Could you upload your &lt;em&gt;sdk_config.h&lt;/em&gt; file, and the declaration of the RTC instance, &lt;code&gt;rtc&lt;/code&gt; (used in &lt;code&gt;nrf_drv_rtc_init()&lt;/code&gt;)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lfclk, rtc issue on SDK13</title><link>https://devzone.nordicsemi.com/thread/92964?ContentTypeID=1</link><pubDate>Wed, 26 Jul 2017 20:11:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b51829c3-5a78-4b51-94ae-87b61697febd</guid><dc:creator>fteng</dc:creator><description>&lt;p&gt;Thx, Jørgen. I used the method to check the error code. It is 0x1001 = NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION in function ble_stack_init() --&amp;gt; SOFTDEVICE_HANDLER_INIT(&amp;amp;clock_lf_cfg, NULL);
clock_lf_cfg is from  NRF_CLOCK_LFCLKSRC -- default setting in pca10040.h
I develop this on an nRF52 base Murata (which I work for) module and I have to port the project to eclipse/GCC due to code size limit in Keil. It doesn&amp;#39;t look like a hardware or toolchain issue to me though, since SDK11 works fine on the same platform. Seems like softdevice in SDK13 takes over RTC and application can&amp;#39;t access it anymore.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lfclk, rtc issue on SDK13</title><link>https://devzone.nordicsemi.com/thread/92965?ContentTypeID=1</link><pubDate>Tue, 25 Jul 2017 13:08:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a81ac9e-7e41-4ffe-9549-50687157da2a</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Have you tried checking for error codes using &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/"&gt;this method&lt;/a&gt;? Aslo, what is your LFCLK settings? Are you testing this on the nRF52 DK or a custom board?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lfclk, rtc issue on SDK13</title><link>https://devzone.nordicsemi.com/thread/92963?ContentTypeID=1</link><pubDate>Mon, 24 Jul 2017 22:45:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b15525b9-e856-4ff7-8bcd-493b7db020f6</guid><dc:creator>fteng</dc:creator><description>&lt;p&gt;Here I ported it to the ble_app_hts_c project in Nordic example codes. lfclk_config() and rtc_config() are the two functions added. It is going to crash in ble_stack_init() in the following order. If I put the two clock functions after ble_stack_init(), they failed. Looks the three functions are fighting each other. It works fine in SDK11 though.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int main(void)
{
...
lfclk_config();                                  //Configure low frequency 32kHz clock
rtc_config();                                    //Configure RTC. 
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
buttons_leds_init(&amp;amp;erase_bonds);
nrf_log_init();
APPL_LOG(&amp;quot;Temperature collector example\r\n&amp;quot;);
ble_stack_init();
...
}
static void lfclk_config(void)
{
    ret_code_t err_code = nrf_drv_clock_init();                        //Initialize the clock source specified in the nrf_drv_config.h file, i.e. the CLOCK_CONFIG_LF_SRC constant
    APP_ERROR_CHECK(err_code);

    nrf_drv_clock_lfclk_request(NULL);
}

static void rtc_config(void)
{
    uint32_t err_code;

    //Initialize RTC instance
    err_code = nrf_drv_rtc_init(&amp;amp;rtc, NULL, rtc_handler);              //Initialize the RTC with callback function rtc_handler. The rtc_handler must be implemented in this applicaiton. Passing NULL here for RTC configuration means that configuration will be taken from the nrf_drv_config.h file.
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_rtc_cc_set(&amp;amp;rtc,0,RTC_CC_VALUE,true);           //Set RTC compare value to trigger interrupt. Configure the interrupt frequency by adjust RTC_CC_VALUE and RTC2_CONFIG_FREQUENCY constant in the nrf_drv_config.h file
    APP_ERROR_CHECK(err_code);

    //Power on RTC instance
    nrf_drv_rtc_enable(&amp;amp;rtc);                                          //Enable RTC
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lfclk, rtc issue on SDK13</title><link>https://devzone.nordicsemi.com/thread/92962?ContentTypeID=1</link><pubDate>Fri, 21 Jul 2017 08:26:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:136f7569-4942-4b92-9d67-3c43e8fd1ce7</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Could you describe the conflicts and problems in more detail? And provide some code snippets showing setup/configuration? I&amp;#39;m not aware of any major changes in these modules.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>