<?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>nRF52 / having 2 processes: 1 master (based on time) and 1 slave</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/35014/nrf52-having-2-processes-1-master-based-on-time-and-1-slave</link><description>Hello, 
 I&amp;#39;ve a process, let&amp;#39;s call it P1, that sends I2C instructions for a LED driver (it&amp;#39;s like an infinite loop of I2C instructions for registers management that have to be done together). 
 I want to do this P1 for a certain time (like for example</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 05 Jun 2018 07:36:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/35014/nrf52-having-2-processes-1-master-based-on-time-and-1-slave" /><item><title>RE: nRF52 / having 2 processes: 1 master (based on time) and 1 slave</title><link>https://devzone.nordicsemi.com/thread/134660?ContentTypeID=1</link><pubDate>Tue, 05 Jun 2018 07:36:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ae290db-7e81-4fbd-bc05-08067439c8da</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The reason I asked about your process/task is because I was wondering whether it was something that you&amp;nbsp;are&amp;nbsp;calling&amp;nbsp;from your main() function, or if you have a process/task running in a &amp;quot;thread&amp;quot; in e.g. FreeRTOS. The difference being the IRQ level of the call. I will get back to the IRQ levels later.&lt;/p&gt;
&lt;p&gt;There are a few models that you can look into.&lt;/p&gt;
&lt;p&gt;The first one is nrfx_timer.c, which has a simple example found in &lt;a href="http://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/"&gt;SDK15.0.0&lt;/a&gt;, found in the path: SDK15\examples\peripheral\timer&lt;/p&gt;
&lt;p&gt;You will see that in this project, a timer is set up, and started in the main() function. It has a timeout handler called&amp;nbsp;timer_led_event_handler(...) which will be called upon timeout.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The physical timer that is used in this example is TIMER0. You can see this in sdk_config.h:&lt;/p&gt;
&lt;p&gt;#define TIMER_ENABLED 1&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;#define TIMER0_ENABLED 1.&lt;/p&gt;
&lt;p&gt;What you can also see in this file is the define:&lt;/p&gt;
&lt;p&gt;#define TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 7&lt;/p&gt;
&lt;p&gt;This means that this timer has the lowest priority available above main(). The priorities are described &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.sds%2Fdita%2Fsoftdevices%2Fs130%2Fprocessor_avail_interrupt_latency%2Fexception_mgmt_sd.html"&gt;here&lt;/a&gt;. So if you are running a task/process or whatever with a higher priority (lower IRQ) than the timeout handler, the timeout handler will not get called until the interrupt with the higher priority is done. If you are running this task/process from main(), then the timeout handler with IRQ = 7 will interrupt the main() function, preform the functions in the interrupt handler, and then return to main().&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please be aware that if you are going to use this timer in a project together with the SoftDevice (for a BLE application), then you must change the timer to use another timer than TIMER0, since this timer is required by the SoftDevice.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The other module you can look into is the app_timer. This is used in most of the examples found in ble_peripheral. It works in a similar way.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 / having 2 processes: 1 master (based on time) and 1 slave</title><link>https://devzone.nordicsemi.com/thread/134633?ContentTypeID=1</link><pubDate>Tue, 05 Jun 2018 02:45:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84e34eba-97a7-4fe0-aa3d-9d013c3751ba</guid><dc:creator>JohnM</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Well I finally managed to acheive my goal using the simple-timer .&lt;/p&gt;
&lt;p&gt;Anyway I think I &amp;#39;ll face this question in the future.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;By &amp;quot;process&amp;quot; I mean a TASK&amp;nbsp; as a function which contains an infinite loop (TASK&amp;nbsp; P2) that has to be stopped by a master function (TASK&amp;nbsp; P1) upon any kind of event (timeout of a timer for example).&amp;nbsp; I think it must be done with an interrupt or something alike but I didn&amp;#39;t find any examples in the SDK so far.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;John.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 / having 2 processes: 1 master (based on time) and 1 slave</title><link>https://devzone.nordicsemi.com/thread/134571?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2018 13:01:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:575ee94d-b18d-42ba-bf35-587f9abbc701</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;What sort of timer did you try to use?&lt;/p&gt;
&lt;p&gt;Have you tried to look into the app_timer module? There is an example in the SDK\examples\timer-project. This should give an interrupt that has a higher priority than your main loop (which I assume that your LED driver is running in?).&lt;/p&gt;
&lt;p&gt;What do you mean with a&amp;nbsp;&amp;quot;process&amp;quot;? Do you use FreeRTOS, or is it running in the main() function of your project?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please note that with a timeout of 10 minutes, you will probably need to configure your timer prescaler.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>