<?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>Delay inside a timer handler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/107087/delay-inside-a-timer-handler</link><description>I am trying to use a delay inside a timer handler, but it appears that the other times stop working and the ANT+messages repeat without update. I am using the S212 soft device and app scheduler. I am guessing that the timer does not like a delay within</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 06 Jan 2024 03:58:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/107087/delay-inside-a-timer-handler" /><item><title>RE: Delay inside a timer handler</title><link>https://devzone.nordicsemi.com/thread/463003?ContentTypeID=1</link><pubDate>Sat, 06 Jan 2024 03:58:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:881813c4-1d4e-4274-ba09-ffa39ebd0e60</guid><dc:creator>SG1</dc:creator><description>&lt;p&gt;Thank you, this worked well!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Delay inside a timer handler</title><link>https://devzone.nordicsemi.com/thread/462614?ContentTypeID=1</link><pubDate>Thu, 04 Jan 2024 06:38:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcc6640a-b02a-4b9d-ba47-da653b60cc6e</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I recommend creating a separate single-shot timer instance to trigger the ADC read operation (APP_TIMER_MODE_SINGLE_SHOT).&amp;nbsp;With this&amp;nbsp;approach you will not have to include any blocking delay code in your timer callback.&lt;/p&gt;
&lt;p&gt;E.g.,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;...
// Create one-shot timer
    err_code = app_timer_create(&amp;amp;&amp;lt;timer id&amp;gt;,
                                APP_TIMER_MODE_SINGLE_SHOT,
                                adc_read_timeout_handler);
    APP_ERROR_CHECK(err_code);
...


void adc_timeout_handler(void * p_context)
{

    UNUSED_PARAMETER(p_context)

    uint32_t err_code;

    reset_adc();
    err_code = app_timer_start(&amp;lt;timer id&amp;gt;, &amp;lt;delay in ticks&amp;gt;, NULL);
    APP_ERROR_CHECK(err_code);
}

void adc_read_timeout_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context)
    
    value = adc_read();
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Bestt regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>