<?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 + BLE UART (NUS), The saadc_callback function doesnt execute.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/43792/saadc-ble-uart-nus-the-saadc_callback-function-doesnt-execute</link><description>Hi 
 I&amp;#39;m using NRF52840 + SDK15.0.0 and softdevice 6.0.0 
 I have joined two program one is ble_app_uart and other SAADC capturing ultrasound noise. (Saadc program works perfectly alone, without softdevice, BLE, etc) 
 The idea is when the device is connected</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 21 Feb 2019 00:50:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/43792/saadc-ble-uart-nus-the-saadc_callback-function-doesnt-execute" /><item><title>RE: SAADC + BLE UART (NUS), The saadc_callback function doesnt execute.</title><link>https://devzone.nordicsemi.com/thread/172204?ContentTypeID=1</link><pubDate>Thu, 21 Feb 2019 00:50:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57f8717d-f638-4183-aaf7-851f9800f2ca</guid><dc:creator>ricardo vasquez rossi</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi&amp;nbsp;&lt;/span&gt;&lt;span&gt;J&amp;oslash;rgen&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;It works perfect!!!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks...&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC + BLE UART (NUS), The saadc_callback function doesnt execute.</title><link>https://devzone.nordicsemi.com/thread/171948?ContentTypeID=1</link><pubDate>Tue, 19 Feb 2019 15:50:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d48f542-7612-4cc4-acab-fdcf4ce4756d</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;In that case there is no need to use ppi to trigger the sample task. My recommendation would be to setup the buffer in the nus_data_handler() and trigger nrf_drv_saadc_sample() once. The SAADC should then fill the buffer and call the saadc_callback when it is done. If you avoid setting up new buffers in the callback, the SAADC should not continue sampling.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC + BLE UART (NUS), The saadc_callback function doesnt execute.</title><link>https://devzone.nordicsemi.com/thread/171919?ContentTypeID=1</link><pubDate>Tue, 19 Feb 2019 14:21:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37e919a6-46cd-4814-a471-0d398b4e0f95</guid><dc:creator>ricardo vasquez rossi</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi&amp;nbsp;&lt;/span&gt;&lt;span&gt;J&amp;oslash;rgen&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I configured&amp;nbsp;the continuous Sampling, because I read 1024 datas (with the sample rate of 200.000 Hz), I used it in the FFT (fast furier transfor)&amp;nbsp; to get the sound frequency spectrum...&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Could I stop the SAADC execute &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;NRF_SAADC-&amp;gt;SAMPLERATE = (0 &amp;lt;&amp;lt; 12);&amp;quot; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;saadc_sampling_event_disable(); &amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;in the main loop?&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;0 =&amp;nbsp;Rate is controlled from SAMPLE task&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NRF_SAADC-&amp;gt;SAMPLERATE = (0 &amp;lt;&amp;lt; 12); //&amp;nbsp;0 =&amp;nbsp;Rate is controlled from SAMPLE task&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for your support..&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Ricardo&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC + BLE UART (NUS), The saadc_callback function doesnt execute.</title><link>https://devzone.nordicsemi.com/thread/171817?ContentTypeID=1</link><pubDate>Tue, 19 Feb 2019 09:01:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3ffb422-1750-46e9-b762-f58daee036d6</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Try removing these two lines from your saadc_init function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_SAADC-&amp;gt;SAMPLERATE  =  (1 &amp;lt;&amp;lt; 12);                                          // Timer mode  
NRF_SAADC-&amp;gt;SAMPLERATE  |= 80;                                                 // 16MHz / 80 counts = 200 000 triggers per second&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;These lines will configure the SAADC in &lt;a href="https://www.nordicsemi.com/DocLib/Content/Product_Spec/nRF52840/latest/saadc?691#concept_continuous"&gt;continuous sampling mode&lt;/a&gt;, overriding the PPI sample task.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC + BLE UART (NUS), The saadc_callback function doesnt execute.</title><link>https://devzone.nordicsemi.com/thread/171772?ContentTypeID=1</link><pubDate>Tue, 19 Feb 2019 03:29:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6826da55-cc31-41b0-a1f8-aefca8df076e</guid><dc:creator>ricardo vasquez rossi</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi&amp;nbsp;&lt;/span&gt;&lt;span&gt;J&amp;oslash;rgen&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;you are right.. something inside happend&amp;nbsp;of nus_data_handler but the SAADC_CALLBACK doesnt run..&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;as your recomendation if enable the SAADC outside of nus_data_handler the saadc start working..&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Resuming I change the following in the code..&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void nus_data_handler(ble_nus_evt_t * p_evt)
{
  
  if (p_evt-&amp;gt;type == BLE_NUS_EVT_RX_DATA)
  {
    Bla.. bla..
    
    bla..  bla...  bla...
    
    
    if(p_evt-&amp;gt;params.rx_data.p_data[0] == &amp;#39;!&amp;#39;)
    {      
      SAACD_Ultrasound_Enable = true;
                   
    }
  }
}


And in the main loop

for (;;)
  {
    if (SAACD_Ultrasound_Enable)
    {
      Datos_Capturados_Ultrasonido = false;
      Capturar_datos_SAADC = true;
      SAACD_Ultrasound_Enable = false;

      saadc_sampling_event_enable();

      //RealFFT_Instance.fftLenReal= Total_samples;

      
      while (!Datos_Capturados_Ultrasonido){}
      saadc_sampling_event_disable();
      Datos_Capturados_Ultrasonido = false;
      nrf_drv_timer_disable(&amp;amp;m_timer);
      
      nrf_drv_saadc_uninit();
      
      nrf_drv_saadc_channel_uninit(0);
     }
    idle_state_handle();

  }
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NOW .. I have the following problem..&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I enabled the Saadc&amp;nbsp; with &amp;quot;&amp;nbsp;&amp;nbsp;saadc_sampling_event_enable(); &amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and the saadc_callback (function)&amp;nbsp; Starting..&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Why I cant stop it with&amp;nbsp;&lt;span&gt;saadc_sampling_event_disable(); ?&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void saadc_sampling_event_disable(void)
{
  ret_code_t err_code = nrf_drv_ppi_channel_disable(m_ppi_channel);
  
  APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;Because when I execute&amp;nbsp;saadc_sampling_event_disable();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;the function&amp;nbsp;saadc_callback&amp;nbsp; still in loop...I know because I send a printf&amp;nbsp; a message to terminal..&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;ONLY i can stop the SAADC when I kill everything.. doing uninit..&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt; nrf_drv_saadc_uninit();&amp;nbsp;&lt;br /&gt; nrf_drv_saadc_channel_uninit(0);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;If I execute Saacd_init() the program goes to Hardfault..&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;is there any&amp;nbsp;simple way to enable and disable again the SAADC?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Ricardo&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC + BLE UART (NUS), The saadc_callback function doesnt execute.</title><link>https://devzone.nordicsemi.com/thread/171715?ContentTypeID=1</link><pubDate>Mon, 18 Feb 2019 17:25:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6282b0a8-bf35-4387-af4a-909099d88e37</guid><dc:creator>ricardo vasquez rossi</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;J&amp;oslash;rgen&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Thanks for your&amp;nbsp; fast answer, YES the programs STUCK in&amp;nbsp; &amp;nbsp; ... while (!Datos_Capturados_Ultrasonido){}&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will do it...&lt;/p&gt;
&lt;p&gt;thanks&lt;/p&gt;
&lt;p&gt;Ricardo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC + BLE UART (NUS), The saadc_callback function doesnt execute.</title><link>https://devzone.nordicsemi.com/thread/171708?ContentTypeID=1</link><pubDate>Mon, 18 Feb 2019 16:26:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d2af13f-ce10-4234-aad9-4277532cc6d1</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It could be some issue with priorities. Are you stuck at the line where you wait for&amp;nbsp;Datos_Capturados_Ultrasonido? I would recommend that you exit the nus_data_handler while sampling, and disable sampling/ppi channel in saadc_callback or main context.&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></channel></rss>