<?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 stuck in calibration + Mesh 5.0.0</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94888/saadc-stuck-in-calibration-mesh-5-0-0</link><description>hi. 
 I have a firmware using standard GATT, now im implementing the mesh layer. 
 Im using SDK 17.0.2 + MESH 5.0.0. (im not using the new sdk connect because it is very difficult to me) 
 in my node i have implemented the SAADC using only the library</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 22 Dec 2022 03:26:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94888/saadc-stuck-in-calibration-mesh-5-0-0" /><item><title>RE: Saadc stuck in calibration + Mesh 5.0.0</title><link>https://devzone.nordicsemi.com/thread/401823?ContentTypeID=1</link><pubDate>Thu, 22 Dec 2022 03:26:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56f42c22-57fc-4684-965a-0038771738f1</guid><dc:creator>ricardo vasquez rossi</dc:creator><description>&lt;p&gt;Hi Joakim&lt;/p&gt;
&lt;p&gt;Thanks for you follow up.&lt;/p&gt;
&lt;p&gt;The principal problem is when we use MESH, the radio has a first priority of the interruptions.&lt;/p&gt;
&lt;p&gt;in my case the problem was to use the WHILE to check&amp;nbsp; nrfx_saadc_is_busy(), to wait if the calibration is ready, this while, generate a anormal behaviour.&lt;/p&gt;
&lt;p&gt;The solution was secuenciate the steps of the SAADC (init, calibration, waiting calibration, measure, un init) this secuencial step I include in the main loop.&lt;/p&gt;
&lt;p&gt;I share part of the code.&lt;/p&gt;
&lt;p&gt;important take a look to &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.meshsdk.v5.0.0/md_doc_user_guide_mesh_interrupt_priorities.html" rel="noopener noreferrer" target="_blank"&gt;this&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;thanks&lt;/p&gt;
&lt;p&gt;Ricardo&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void) {
  bsp_board_init(BSP_INIT_LEDS);
  Temp_adc[0]=NRF_SAADC_INPUT_AIN2;
  Temp_adc[1]=NRF_SAADC_INPUT_AIN4;
  ret_code_t err_code;
  
  __LOG_INIT(LOG_SRC_APP, LOG_LEVEL_DBG1, LOG_CALLBACK_DEFAULT);
  __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;----- BLE Mesh App Demo PARA NODO -----\n&amp;quot;);

  ERROR_CHECK(app_timer_init());
  mesh_helper_init();
  mesh_helper_start();

  
  ERROR_CHECK(app_timer_create(&amp;amp;timer, APP_TIMER_MODE_REPEATED, periodic_Measure));
  ERROR_CHECK(app_timer_start(timer, APP_TIMER_TICKS(5000), NULL));

  ERROR_CHECK(app_timer_create(&amp;amp;timer2, APP_TIMER_MODE_REPEATED, periodic_send));
  ERROR_CHECK(app_timer_start(timer2, APP_TIMER_TICKS(500), NULL));

  while (1) {
      sd_app_evt_wait();
    
      if (Step_Process==Temp_init)
      {
      bsp_board_led_on(1);
      Temperature_voltage_init(Temp_adc[Adc_temp]);
      Step_Process = Temp_calibration;
      }
      if (Step_Process == Temp_calibration) {
        err_code = nrfx_saadc_calibrate_offset();
        APP_ERROR_CHECK(err_code);
        Step_Process = Temp_cal_wait;
      }

      if (Step_Process == Temp_cal_wait) {
        if (!nrfx_saadc_is_busy()) {
          Step_Process = Temp_measure;
        }
      }
      if (Step_Process == Temp_measure) {
        adc_buf_NPT_result[Adc_temp] = GetTemperature();
        nrf_drv_saadc_channel_uninit(0);
        nrf_drv_saadc_uninit();
        if (Adc_temp &amp;lt; 1) {
          Adc_temp++;
          Step_Process = Temp_init;
        } else {
          
          Adc_temp=0;
          Sonda_temp1 = Temp_NTC(adc_buf_NPT_result[0]);
          Sonda_temp2 = Temp_NTC(adc_buf_NPT_result[1]);
          temp = Sonda_temp1;
          Measuring_ok = true;
          Step_Process = Temp_Finish;

        }
      }
  }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Saadc stuck in calibration + Mesh 5.0.0</title><link>https://devzone.nordicsemi.com/thread/401814?ContentTypeID=1</link><pubDate>Wed, 21 Dec 2022 23:22:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a68b2b0-7e87-4739-9218-b2be62fb14fa</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Saw you created another ticket for this, where you got a suggestion from one of my colleagues; &lt;br /&gt;&amp;quot;It looks to me like you always calibrate before measurement. In that case I would likely have enabled saadcs interrupt on CALIBRATEDONE event, then&amp;nbsp;configured an app_timer to trigger an nrfx_saadc_calibrate_offset() on given intervals, and then on each CALIBRATEDONE event in the saadc interrupt you can execute an adc sample conversion. The actual sample value(s) can be stored in some global buffer that is&amp;nbsp;fetched by calling&amp;nbsp;GetTemperature().&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Br,&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Saadc stuck in calibration + Mesh 5.0.0</title><link>https://devzone.nordicsemi.com/thread/401167?ContentTypeID=1</link><pubDate>Mon, 19 Dec 2022 04:10:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2db61fd-4517-4c23-ab50-21e17520d5f2</guid><dc:creator>ricardo vasquez rossi</dc:creator><description>&lt;p&gt;Hi Joakim&lt;/p&gt;
&lt;p&gt;thanks for your answew&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Do you want to put the device to sleep (system on) while waiting?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-No,&amp;nbsp; I dont&amp;nbsp; want to put the sleep (system on)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you see any error codes or logs?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;the device does not send any error. only it is stucking in the while cycle, waiting the saadc finish.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;the objective of the firmware is&amp;nbsp;the device belong a mesh, and send the temperature, the temeprature is measure by ADC fuction. this fuction WORKS in a standad firmware using GATT Bluetooth LE broadcasting.&lt;/p&gt;
&lt;p&gt;But now, when the device using MESH&amp;nbsp;topology, when I want to calibrate the ADC, the cycle stuck when waiting to nrfx_saadc_is_busy()&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;are there some restriction using MESH and reading/calibrating SAADC at the same time?&lt;/p&gt;
&lt;p&gt;&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 stuck in calibration + Mesh 5.0.0</title><link>https://devzone.nordicsemi.com/thread/401161?ContentTypeID=1</link><pubDate>Mon, 19 Dec 2022 01:04:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a140872f-d032-4f58-9327-a578569fd823</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi Ricardo!&lt;/p&gt;
&lt;p&gt;Do you want to put the device to sleep (system on) while waiting?&lt;/p&gt;
[quote user=""]the program stuck in the&amp;nbsp;while (nrfx_saadc_is_busy())[/quote]
&lt;p&gt;Can you see any error codes or logs?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Br, &lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>