<?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>How to set NRF52840 DK SAADC Sampling at 200 kHZ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44312/how-to-set-nrf52840-dk-saadc-sampling-at-200-khz</link><description>Dear All, 
 I am using NRF52840 DK with SDK13.0 . I am trying to use one SAADC channel (CH 1) to record input signals at 200 kHz to fill a buffer of 2000 points . After the buffer is full (2000 points collected), the data will be trasfered to my PC via</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 06 Mar 2019 15:02:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44312/how-to-set-nrf52840-dk-saadc-sampling-at-200-khz" /><item><title>RE: How to set NRF52840 DK SAADC Sampling at 200 kHZ?</title><link>https://devzone.nordicsemi.com/thread/174614?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2019 15:02:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0ef12ab-1cc8-47c8-a44c-43bda17e53cc</guid><dc:creator>IC_Hai</dc:creator><description>&lt;p&gt;Do you have any codes to share on this? I could not understand why sending 2000 bytes is that difficult over BLE.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set NRF52840 DK SAADC Sampling at 200 kHZ?</title><link>https://devzone.nordicsemi.com/thread/174492?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2019 10:14:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56271e7f-c66d-4107-b937-89ec7066ace4</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Do you receive error&amp;nbsp;&lt;a title="Not enough resources for operation." href="https://www.nordicsemi.com/DocLib/Content/SoftDevice_API_Doc/S132/v6-1-0/group__nrf__error#gac94383171545e604e8347a044e8be13f"&gt;NRF_ERROR_RESOURCES&lt;/a&gt;? You either have to keep calling the function when you receive this error until you get NRF_SUCCESS. A better option is to wait for the &lt;a href="https://www.nordicsemi.com/DocLib/Content/SoftDevice_API_Doc/S132/v6-1-0/group_ble_gatts_enumerations#ggae537647902af1b05c1e32f12d6b401c7afab96bfa9918017082235f7664919f9d"&gt;BLE_GATTS_EVT_HVN_TX_COMPLETE&lt;/a&gt;&amp;nbsp;event when you get this error.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set NRF52840 DK SAADC Sampling at 200 kHZ?</title><link>https://devzone.nordicsemi.com/thread/174485?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2019 10:06:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efaa56db-7fd0-4a07-be80-d1f6c1c7aeb6</guid><dc:creator>IC_Hai</dc:creator><description>&lt;p&gt;Hi Jorgen,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for the information. Yes, I was able to send like 15 packages (300 bytes data), but I got that error when I tried t send more.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you have any solutions for that? I checked the&amp;nbsp;&lt;strong&gt;ble_app_att_mtu_throughput&lt;/strong&gt; example in SDK 15.0, but it seems that the data are not processed in the receiver side. I was trying to do some programing in the on_hvx() function to get the data, but not successful. Please let me know the proper way to transmit the data.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Hai&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set NRF52840 DK SAADC Sampling at 200 kHZ?</title><link>https://devzone.nordicsemi.com/thread/174481?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2019 09:52:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3574679-7b18-4be5-8878-9dc648d05185</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;My guess would be that you get another error code than&amp;nbsp;NRF_ERROR_INVALID_STATE when calling&amp;nbsp;ble_nus_string_send() 100 times, and you end up in the error handler. Note that there is a limited number of buffers available for sending notifications, which is what this function does internally. In general, it is also not recommended to spend long time in handlers/interrupt context, as this will block other lower priority event from being handled.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set NRF52840 DK SAADC Sampling at 200 kHZ?</title><link>https://devzone.nordicsemi.com/thread/174386?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 21:08:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:797eaefc-701d-4f79-bf80-36fea00c9cb8</guid><dc:creator>IC_Hai</dc:creator><description>&lt;p&gt;Hi Jorgen,&lt;/p&gt;
&lt;p&gt;Yes, I have &amp;quot;channel_0_config.acq_time = NRF_SAADC_ACQTIME_3US&amp;quot; in&amp;nbsp;void saadc_init(void). So I guess I can fill 2000 points in the buffer successfully.&lt;/p&gt;
&lt;p&gt;When I try to divide the 2000 points (12 bits each, 4000 bytes) into 200 packages and send them to a NRF52832 DK receiver connected to my PC and controlled by NRF Connect, I could not recevie the packages, and always get this error&amp;nbsp;&lt;span&gt;&amp;quot;BLE_HCI_CONNECTION_TIMEOUT&amp;quot; from the receiver.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This is the saadc_callback function I am using.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
    
	  if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)
     {
        saadc_sampling_event_disable();
	    bsp_board_led_invert(1);
	    ret_code_t err_code;
        uint16_t adc_value;
        uint8_t value[SAADC_SAMPLES_IN_BUFFER*2];
		uint8_t subvalue[20];

        err_code = nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, SAADC_SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);

        for (int i = 0; i &amp;lt; SAADC_SAMPLES_IN_BUFFER; i++)
        {
            adc_value = p_event-&amp;gt;data.done.p_buffer[i];
            value[i*2] = adc_value;
            value[(i*2)+1] = adc_value &amp;gt;&amp;gt; 8;
        }
				
		for (uint16_t indx_j = 0; indx_j &amp;lt; 20; indx_j++)//SAADC_SAMPLES_IN_BUFFER*2/20
		{
			for (uint16_t ind_m = 0; ind_m &amp;lt; 20; ind_m++)
			{
				subvalue[ind_m] = value[indx_j*20+ind_m];
			}
			err_code = ble_nus_string_send(&amp;amp;m_nus, subvalue, 20);
            
            if (err_code != NRF_ERROR_INVALID_STATE) 
            {
                APP_ERROR_CHECK(err_code);
            }
		}
        m_adc_evt_counter++;
		nrf_delay_ms(500);
		saadc_sampling_event_enable();
    }
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Would you please help me with this issue?&lt;/p&gt;
&lt;p&gt;Many thanks,&lt;/p&gt;
&lt;p&gt;Hai&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set NRF52840 DK SAADC Sampling at 200 kHZ?</title><link>https://devzone.nordicsemi.com/thread/174171?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 08:46:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b7659f7-c66b-4771-8a56-534d16f520e9</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;In order to achieve 200 kHz sample rate, you need to set&amp;nbsp;&lt;a href="https://github.com/NordicPlayground/nRF52-ADC-examples/blob/master/saadc_low_power/main.c#L222"&gt;&lt;span&gt;acq_time&lt;/span&gt;&lt;/a&gt;&lt;span&gt;&amp;nbsp;to&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_SAADC_ACQTIME_3US.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You can then trigger the sample task through PPI from TIMER or RTC event until you have filled the 2000 samples buffer. There is no mode that will capture 2000 samples for you from a single sample task.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set NRF52840 DK SAADC Sampling at 200 kHZ?</title><link>https://devzone.nordicsemi.com/thread/174082?ContentTypeID=1</link><pubDate>Mon, 04 Mar 2019 17:41:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0af7fa6-369e-4c9e-a198-4160a3362c66</guid><dc:creator>IC_Hai</dc:creator><description>&lt;p&gt;This is my settings based on the example in Github.&amp;nbsp;&lt;a href="https://github.com/NordicPlayground/nRF52-ADC-examples/blob/master/ble_app_uart__saadc_timer_driven__scan_mode/main.c"&gt;https://github.com/NordicPlayground/nRF52-ADC-examples/blob/master/ble_app_uart__saadc_timer_driven__scan_mode/main.c&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;#define SAADC_SAMPLES_IN_BUFFER 2000&lt;br /&gt;#define SAADC_SAMPLE_RATE 10 /**&amp;lt; SAADC sample rate in us. */&lt;/p&gt;
&lt;p&gt;In the&amp;nbsp;&lt;strong&gt;void saadc_sampling_event_init(void)&lt;/strong&gt; function, I did these changes.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;void saadc_sampling_event_init(void)&lt;/em&gt;&lt;br /&gt;&lt;em&gt;{&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;......&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;timer_config.frequency = NRF_TIMER_FREQ_16MHz;//62500Hz;//31250Hz;//NRF_TIMER_FREQ_;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;......&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;uint32_t ticks = nrf_drv_timer_us_to_ticks(&amp;amp;m_timer,SAADC_SAMPLE_RATE);&lt;/em&gt;&lt;br /&gt;&lt;em&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;......&lt;/em&gt;&lt;br /&gt;&lt;em&gt;}&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;in the&amp;nbsp;&lt;strong&gt;void saadc_callback(nrf_drv_saadc_evt_t const * p_event)&amp;nbsp;&lt;/strong&gt;function, I did the following changes.&lt;/p&gt;
&lt;p&gt;void saadc_callback(nrf_drv_saadc_evt_t const * p_event)&lt;br /&gt;{&lt;br /&gt; saadc_sampling_event_disable();&lt;br /&gt; bsp_board_led_invert(1);&lt;br /&gt; if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)&lt;br /&gt; {&lt;br /&gt; ret_code_t err_code;&lt;br /&gt; uint16_t adc_value;&lt;br /&gt; uint8_t value[SAADC_SAMPLES_IN_BUFFER*2];&lt;br /&gt; uint8_t subvalue[20];&lt;/p&gt;
&lt;p&gt;err_code = nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, SAADC_SAMPLES_IN_BUFFER);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;for (int i = 0; i &amp;lt; SAADC_SAMPLES_IN_BUFFER; i++)&lt;br /&gt; {&lt;br /&gt; adc_value = p_event-&amp;gt;data.done.p_buffer[i];&lt;br /&gt; value[i*2] = adc_value;&lt;br /&gt; value[(i*2)+1] = adc_value &amp;gt;&amp;gt; 8;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; for (uint16_t indx_j = 0; indx_j &amp;lt;SAADC_SAMPLES_IN_BUFFER*2/20; indx_j++)//SAADC_SAMPLES_IN_BUFFER*2/20&lt;br /&gt; {&lt;br /&gt; for (uint16_t ind_m = 0; ind_m &amp;lt; 20; ind_m++)&lt;br /&gt; {&lt;br /&gt; subvalue[ind_m] = value[indx_j*20+ind_m];&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; err_code = ble_nus_string_send(&amp;amp;m_nus, subvalue, 20);&lt;br /&gt; if (err_code != NRF_ERROR_INVALID_STATE) &lt;br /&gt; {&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; }&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;m_adc_evt_counter++;&lt;br /&gt; nrf_delay_ms(500);&lt;br /&gt; saadc_sampling_event_enable();&lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;I always get this error &amp;quot;BLE_HCI_CONNECTION_TIMEOUT&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>