<?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 and RTC_TIMER_0 at the same time - problems</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/47723/app_timer-and-rtc_timer_0-at-the-same-time---problems</link><description>Good morning, 
 I have been asked to merge the code developed by two independent teams. Of course, each one of them took their decision on the management of time, and of course they took different ways :) . I am currently working on SDK 15.0.0 
 So, I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 19 Jun 2019 13:23:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/47723/app_timer-and-rtc_timer_0-at-the-same-time---problems" /><item><title>RE: APP_TIMER and RTC_TIMER_0 at the same time - problems</title><link>https://devzone.nordicsemi.com/thread/193694?ContentTypeID=1</link><pubDate>Wed, 19 Jun 2019 13:23:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a25c465-8715-4683-9bbf-2f4dc17f9ba9</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Where do you initialize the SPI transfer? Is it in main or interrupt context? How many app timers are you running, and do you start/stop these somewhere in the application?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: APP_TIMER and RTC_TIMER_0 at the same time - problems</title><link>https://devzone.nordicsemi.com/thread/191979?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2019 09:18:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9e715cf-eb4b-4803-b852-f88733d7908d</guid><dc:creator>lbe</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;sorry for the late reply, but I was on holidays until today.&lt;/p&gt;
&lt;p&gt;The code is pretty complex (and confidential), so I cannot really post pieces of it. Furthermore, I was not able to reproduce the issue on a clean project....if I have a simple project with the 2 timers, it works fine.&lt;/p&gt;
&lt;p&gt;What I can show is exactly where the problem happens, as I mentioned in my second comment.&lt;/p&gt;
&lt;p&gt;We are in the situation where the two timers (RTC0 and RTC1) have already been started, the LFCLK is correctly running and (apparently) everything goes without problems.&lt;/p&gt;
&lt;p&gt;The operation which blocks the system is a configuration of a peripheral using SPI configuration.&lt;/p&gt;
&lt;p&gt;The SPI is configured using the default config given by Nordic, i.e.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define NRF_DRV_SPI_DEFAULT_CONFIG                           \
{                                                            \
    .sck_pin      = NRF_DRV_SPI_PIN_NOT_USED,                \
    .mosi_pin     = NRF_DRV_SPI_PIN_NOT_USED,                \
    .miso_pin     = NRF_DRV_SPI_PIN_NOT_USED,                \
    .ss_pin       = NRF_DRV_SPI_PIN_NOT_USED,                \
    .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY,         \
    .orc          = 0xFF,                                    \
    .frequency    = NRF_DRV_SPI_FREQ_4M,                     \
    .mode         = NRF_DRV_SPI_MODE_0,                      \
    .bit_order    = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST,         \
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;and the system is stuck at this operation&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	spi_xfer_done = false;

	nrf_drv_spi_transfer(&amp;amp;spi_unit, tx, 1, rx, 1);
	while (!spi_xfer_done)
	{
		__WFE();
	}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As mentioned before, if I run the same code but I comment out the instruction&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    NVIC_EnableIRQ(SWI_IRQn); 
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;in the file app_timer.c , in function app_timer_init(void), the software is able to continue without blocking at the spi transfer.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As you suggest in your comment, I too suspect that there is some issue with irq priorities, but changing them did not seem to fix the problem. I tried to modify the NRF_DRV_SPI_DEFAULT_CONFIG and to give it a higher priority (2 for example), but this did not seem to help.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Any other suggestion would be greatly appreciated!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: APP_TIMER and RTC_TIMER_0 at the same time - problems</title><link>https://devzone.nordicsemi.com/thread/189383?ContentTypeID=1</link><pubDate>Mon, 27 May 2019 14:41:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a215baf5-d52f-4245-918d-b20a24ee95c9</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There should not be any issues with using these resources together, but it could be that you have some priority issues in your application. Have you started the LFCLK? This is required by the RTC to be running.&lt;/p&gt;
&lt;p&gt;Can you post some code/example project that shows what you are doing and can be used to reproduce the issue?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: APP_TIMER and RTC_TIMER_0 at the same time - problems</title><link>https://devzone.nordicsemi.com/thread/189085?ContentTypeID=1</link><pubDate>Fri, 24 May 2019 14:25:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9ececbc-c225-442b-a9e0-f043c552f454</guid><dc:creator>lbe</dc:creator><description>&lt;p&gt;I forgot to mention that the problem seems also related to a communication using the SPI.....If the NVIC_ENABLE_IRQ instruction is commented out everything works fine, otherwise it seems that the firmware is locked in a while cycle waiting for a _spi_xfer_over boolean to become true....is it possible that the app_timer interrupt interferes with the SPI interrupt?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>