<?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>SAADC missing event</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61943/saadc-missing-event</link><description>Hello. 
 I have a issue about missing NRF_DRV_SAADC_EVT_DONE event in saadc handler. 
 setup is 52832, SDK 15.3.0, S332. enable ANT, BLE 
 for battery, sensor, I use 2 adc channel. 
 buffer size is 2. 
 like &amp;#39; adc_buffer[2][ADC_BUFFER_SIZE] &amp;#39;. 
 adc interval</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 16 Jun 2020 01:54:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61943/saadc-missing-event" /><item><title>RE: SAADC missing event</title><link>https://devzone.nordicsemi.com/thread/255117?ContentTypeID=1</link><pubDate>Tue, 16 Jun 2020 01:54:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bc413a0-d0ae-416f-b7a1-a844a787bca8</guid><dc:creator>BEN_HB</dc:creator><description>&lt;p&gt;Thank you for advices. If more question, I write new ticket.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC missing event</title><link>https://devzone.nordicsemi.com/thread/254981?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2020 11:29:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ece9fe63-2749-4341-94bc-04a2016777c5</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;That&amp;#39;s quite a big difference in current consumption.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;If you want a more reliable 10ms sample event I suggest you use the RTC (not the app_timer) with an interrupt priority level of 2(See S132&amp;nbsp;&lt;a title="Interrupt priority levels" href="https://infocenter.nordicsemi.com/topic/sds_s132/SDS/s1xx/processor_avail_interrupt_latency/exception_mgmt_sd.html?cp=4_6_2_0_15_1"&gt;Interrupt priority levels&lt;/a&gt;), set to trigger a compare event at 10ms, where you init the SAADC and manually take one sample with&amp;nbsp;&lt;a title="nrfx_saadc_sample" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrfx__saadc.html?cp=7_1_6_9_0_30_1_20#gaf117e087540c455a6dfe05f258d118f0"&gt;nrfx_saadc_sample&lt;/a&gt;. Un-init after each sample and repeat.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC missing event</title><link>https://devzone.nordicsemi.com/thread/253906?ContentTypeID=1</link><pubDate>Tue, 09 Jun 2020 01:44:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:302effc7-8df1-4b2a-8f27-6ded9d8ee25b</guid><dc:creator>BEN_HB</dc:creator><description>&lt;p&gt;1. if prescaler = 0, the timer gap is tiny, so avoid exception from priority execution?&lt;/p&gt;
&lt;p&gt;2. using init &amp;amp; uninit : power is about 315uA, if not uninit, power is about 2.12mA,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adc uninit include ppi uninit also.&lt;/p&gt;
&lt;p&gt;init&amp;amp;uninit : using app timer and rtc (8ms + 2ms)&lt;/p&gt;
&lt;p&gt;not uninit : only use rtc. adc init one time when boot. it uninit before sleep. rtc prescaler is 31.&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rtc start -&amp;gt; rtc event -&amp;gt; rtc interrupt -&amp;gt; rtc restart in rtc handler.&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; get value is normal. issue is power consumption. 2.12mA is too high.&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my opinion is if not excute uninit adc, ppi use dma, it drain more power.&lt;/p&gt;
&lt;p&gt;setup is same. ble + ant + watchdog + app timer + rtc + adc(using ppi)&lt;/p&gt;
&lt;p&gt;Thank you so much&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC missing event</title><link>https://devzone.nordicsemi.com/thread/253777?ContentTypeID=1</link><pubDate>Mon, 08 Jun 2020 11:58:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bdb6a850-5a7f-46ab-b78c-34c260462710</guid><dc:creator>haakonsh</dc:creator><description>&lt;ol&gt;
&lt;li&gt;Correct.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Why do you need to uninitialize the SAADC between every 10ms sample? What&amp;#39;s the difference in current consumption if you unititialize and not?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC missing event</title><link>https://devzone.nordicsemi.com/thread/253664?ContentTypeID=1</link><pubDate>Mon, 08 Jun 2020 01:54:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aea990d1-2738-4aa9-923f-cc596da20468</guid><dc:creator>BEN_HB</dc:creator><description>&lt;p&gt;sorry too late reply.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;1. nrf_drv_rtc_cc_set function, last arguement is false, is it no interrupt, just event and it guarantee to happen event regardless BLE and ANT priority?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(cause rtc handler there is nothing. no need interrupt. only using adc event for ppi)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. also consider use only RTC , without app timer. however, for reducing power consumption, init &amp;amp; uninit every 10ms. So before event is happen, need to init adc.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;adc init -&amp;gt; rtc_cc_set -&amp;gt; rtc event raise -&amp;gt; adc sample -&amp;gt; get value -&amp;gt; adc uninit (need)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;if rtc event -&amp;gt; adc init -&amp;gt; can&amp;#39;t sample adc.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC missing event</title><link>https://devzone.nordicsemi.com/thread/252697?ContentTypeID=1</link><pubDate>Tue, 02 Jun 2020 11:28:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2169c469-c665-4ce9-a79f-4470bf651428</guid><dc:creator>haakonsh</dc:creator><description>[quote user="BEN_HB"]app timer interval is 9ms, rtc timer is 1ms (i used prescaler is 31, it meas 1/1024s, almost 1ms)[/quote]
&lt;p&gt;If you include interrupts into this state machine then you will have no guarantee that you will sample every 10ms as both BLE and ANT event will have execution priority.&lt;br /&gt;&lt;br /&gt;If you set your RTC prescaler to zero and use a COMPARE event at 328 ticks you will get a COMPARE event every 328 * 30.51µs = 10.00728 ms.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC missing event</title><link>https://devzone.nordicsemi.com/thread/252545?ContentTypeID=1</link><pubDate>Mon, 01 Jun 2020 02:04:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4afd3f7e-bed6-4e4e-9bd4-6f6c0892b328</guid><dc:creator>BEN_HB</dc:creator><description>&lt;p&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void adc_init()
{  
  ret_code_t err_code;     

  err_code = nrf_drv_saadc_init(&amp;amp;saadc_config, user_adc_saadc_handler); 
  APP_ERROR_CHECK(err_code);

  channel_config.pin_p = (nrf_saadc_input_t)(NRF_SAADC_INPUT_AIN0);
  err_code = nrf_drv_saadc_channel_init(BATTERY_SAADC_CHANNEL, &amp;amp;channel_config); 
  APP_ERROR_CHECK(err_code);

  channel_config.pin_p = (nrf_saadc_input_t)(NRF_SAADC_INPUT_AIN1);
  err_code = nrf_drv_saadc_channel_init(ADC_SAADC_CHANNEL, &amp;amp;channel_config); 
  APP_ERROR_CHECK(err_code);

  err_code = nrf_drv_saadc_buffer_convert(adc_buffer[0], ADC_BUFFER_SIZE); 
  APP_ERROR_CHECK(err_code);

  err_code = nrf_drv_saadc_buffer_convert(adc_buffer[1], ADC_BUFFER_SIZE); 
  APP_ERROR_CHECK(err_code);

  adc_sample_event_init();  
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void adc_config_init(nrf_drv_saadc_config_t *saadc_config, nrf_saadc_channel_config_t *channel_config)
{
  memset(saadc_config, 0 , sizeof(*saadc_config));
  saadc_config-&amp;gt;resolution         = (nrf_saadc_resolution_t)NRFX_SAADC_CONFIG_RESOLUTION; // 12bit
  saadc_config-&amp;gt;oversample         = (nrf_saadc_oversample_t)NRFX_SAADC_CONFIG_OVERSAMPLE; // no oversample
  saadc_config-&amp;gt;interrupt_priority = NRFX_SAADC_CONFIG_IRQ_PRIORITY; // priority 6
  saadc_config-&amp;gt;low_power_mode     = NRFX_SAADC_CONFIG_LP_MODE; // LP mode yes

  memset(channel_config, 0 , sizeof(*channel_config));
  channel_config-&amp;gt;resistor_p   = NRF_SAADC_RESISTOR_DISABLED;
  channel_config-&amp;gt;resistor_n   = NRF_SAADC_RESISTOR_DISABLED;
  channel_config-&amp;gt;gain         = NRF_SAADC_GAIN1_6;
  channel_config-&amp;gt;reference    = NRF_SAADC_REFERENCE_INTERNAL;
  channel_config-&amp;gt;acq_time     = NRF_SAADC_ACQTIME_10US;
  channel_config-&amp;gt;mode         = NRF_SAADC_MODE_SINGLE_ENDED;
  channel_config-&amp;gt;burst        = NRF_SAADC_BURST_DISABLED;
  channel_config-&amp;gt;pin_p        = (nrf_saadc_input_t)(NRF_SAADC_INPUT_AIN0);
  channel_config-&amp;gt;pin_n        = NRF_SAADC_INPUT_DISABLED;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void adc_sample_event_init()
{
    ret_code_t err_code;

    err_code = nrf_drv_ppi_init(); 
    APP_ERROR_CHECK(err_code);


    uint32_t timer_compare_event_addr = rtc_get_adc_event_addr(); 
    uint32_t saadc_sample_task_addr   = nrf_drv_saadc_sample_task_get(); 

    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;m_ppi_channel);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_assign(m_ppi_channel, 
                                          timer_compare_event_addr,
                                          saadc_sample_task_addr);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_enable(m_ppi_channel); // PPI enable

    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void rtc_adc_timer_start()
{
   ret_code_t err_code;
    
   uint32_t current = nrf_drv_rtc_counter_get(&amp;amp;rtc);
   
   err_code = nrf_drv_rtc_cc_set(&amp;amp;rtc, RTC_ADC_CHANNEL, rtc_check_overflow_cc_set(current, ADC_TIMER_INTERVAL), true);
   APP_ERROR_CHECK(err_code);   
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void rtc_handler(nrf_drv_rtc_int_type_t int_type)
{  
  switch(int_type)
  {
    case NRF_DRV_RTC_INT_COMPARE0  :  
    
      break;   

    case NRF_DRV_RTC_INT_COMPARE1  :  
  
      break;
      
    case NRF_DRV_RTC_INT_COMPARE2  : 
     
      break;
  
    default :
      break;
  }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;more detail, process is below&lt;/p&gt;
&lt;p&gt;I want get adc value interval 10ms.&lt;/p&gt;
&lt;p&gt;to use ppi, need event address. app timer not support func get event address.&lt;/p&gt;
&lt;p&gt;so I used rtc timer. (reason choosing rtc, need low power consumption.)&lt;/p&gt;
&lt;p&gt;app timer interval is 9ms, rtc timer is 1ms (i used prescaler is 31, it meas 1/1024s, almost 1ms)&lt;/p&gt;
&lt;p&gt;after 9ms, app timer handler start rtc timer setting 1ms using nrf_drv_rtc_cc_set function&lt;/p&gt;
&lt;p&gt;passing 1ms, rtc timer send event to ppi, and start measure adc value.&lt;/p&gt;
&lt;p&gt;on rtc handler, there is doing nothing.&lt;/p&gt;
&lt;p&gt;here is issue, sometimes rtc timer is not send event to ppi.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC missing event</title><link>https://devzone.nordicsemi.com/thread/252356?ContentTypeID=1</link><pubDate>Fri, 29 May 2020 10:02:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bff403dd-fe1d-4248-850a-6ff35196b053</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;If you use PPI you don&amp;#39;t need the RTC COMPARE interrupt at all, just the event.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;And I think you need more than one count after &amp;quot;current&amp;quot;.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Do you mind sharing your code with some comments? I think you might be on the wrong track.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC missing event</title><link>https://devzone.nordicsemi.com/thread/252319?ContentTypeID=1</link><pubDate>Fri, 29 May 2020 08:42:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:becc2b91-8cd3-4e24-bdbd-e13e5f1635b9</guid><dc:creator>BEN_HB</dc:creator><description>&lt;p&gt;Thank you.&lt;br /&gt;I found one more.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;cause rtc timer interrupt is not working. so saadc sample is not trigger.&lt;/p&gt;
&lt;p&gt;rtc timer interval is 1ms.&lt;/p&gt;
&lt;p&gt;rtc prescaler is 31. (need 1024/s)&lt;/p&gt;
&lt;p&gt;it used&amp;nbsp;nrf_drv_rtc_cc_set(adc_channel, current, current +1, true).&lt;/p&gt;
&lt;p&gt;ex) if current is 0x53, it interrupt count is 0x54.&lt;/p&gt;
&lt;p&gt;is it too tight?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC missing event</title><link>https://devzone.nordicsemi.com/thread/252315?ContentTypeID=1</link><pubDate>Fri, 29 May 2020 08:12:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f01e7bd1-afed-4a40-9473-cb67d0559c10</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;You need to look for the END event, not the DONE event, as the END event signifies that the buffer has been filled and transferred to RAM. The DONE event&amp;nbsp;does not have its interrupt enabled in the driver and will not generate an interrupt.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>