<?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>Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49510/try-to-transfert-adc-sampling-signal-by-ble</link><description>Hello, 
 I am trying to transfer a signal sampled on AN0 (P0.02) at 16kHz via Bluetooth using an ATT MTU of 247 and a 2MBPS PHY speed. The basis project used is examples \ ble_central_and_peripheral \ experimental \ ble_app_att_mtu_throughput. 
 I also</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 06 Aug 2019 16:41:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49510/try-to-transfert-adc-sampling-signal-by-ble" /><item><title>RE: Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/thread/202678?ContentTypeID=1</link><pubDate>Tue, 06 Aug 2019 16:41:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94293612-ab0e-43af-9417-1ae7aa0c8628</guid><dc:creator>merlin chendjou</dc:creator><description>&lt;p&gt;&lt;span&gt;Dear sir, &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;After synchronizing the samples signal, I would like to send them to my ble central.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt; To test the transfer, I set up the device code below, I want to call a timer every 4ms to transfer 64 bytes to ble central so&amp;nbsp;i use the example examples / ble_central / ble_app_uart_c&amp;nbsp; for data recovery.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt; I modified the code to configure ATT MTU = 244, gatt data len = 244, PHY update 2MBPS. To ensure synchronization, the module ble_central toggle the LED at each reception.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt; Problem: I notice that I have a synchronization problem for transfers below 30ms. How can I solve this problem?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks in advance for your answer.&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
/**@cond To Make Doxygen skip documentation generation for this file.
 * @{
 */

#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;


#include &amp;quot;sdk_config.h&amp;quot;
#include &amp;quot;nordic_common.h&amp;quot;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;ble.h&amp;quot;
#include &amp;quot;ble_gatt.h&amp;quot;
#include &amp;quot;ble_hci.h&amp;quot;
#include &amp;quot;ble_advdata.h&amp;quot;
#include &amp;quot;ble_conn_params.h&amp;quot;
#include &amp;quot;nrf_sdh.h&amp;quot;
#include &amp;quot;nrf_sdh_soc.h&amp;quot;
#include &amp;quot;nrf_sdh_ble.h&amp;quot;
#include &amp;quot;nrf_ble_qwr.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;
#include &amp;quot;nrf_ble_gatt.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;

#include &amp;quot;ble_srv_common.h&amp;quot;
#include &amp;quot;bsp_btn_ble.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_pwr_mgmt.h&amp;quot;
#include &amp;quot;nrf_ble_scan.h&amp;quot;
#include &amp;quot;nrf_drv_i2s.h&amp;quot;
#include &amp;quot;app_uart.h&amp;quot;
#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;saadc_service.h&amp;quot;
#include &amp;quot;sdt_sample_transfer_service.h&amp;quot;
#include &amp;quot;ble_advertising.h&amp;quot;
#include &amp;quot;ble_nus_c.h&amp;quot;

APP_TIMER_DEF(m_sample_delay_timer_id);

#if defined (UART_PRESENT)
#include &amp;quot;nrf_uart.h&amp;quot;
#endif
#if defined (UARTE_PRESENT)
#include &amp;quot;nrf_uarte.h&amp;quot;
#endif


#define MAIN_DEBUG
#ifdef MAIN_DEBUG
#define DEBUG(x,y...) printf (&amp;quot;(%s:%d) &amp;quot; x &amp;quot;\n&amp;quot;, __func__ , __LINE__,  ## y)
#else
#define DEBUG(x,y...)
#endif


#define UART_TX_BUF_SIZE                256                                         /**&amp;lt; UART TX buffer size. */
#define UART_RX_BUF_SIZE                256                                         /**&amp;lt; UART RX buffer size. */

#define DATA_LENGTH_DEFAULT             27                                              /**&amp;lt; The stack default data length. */
#define DATA_LENGTH_MAX                 251                                             /**&amp;lt; The stack maximum data length. */

#define CONN_INTERVAL_DEFAULT           (uint16_t)(MSEC_TO_UNITS(7.5, UNIT_1_25_MS))    /**&amp;lt; Default connection interval used at connection establishment by central side. */

#define CONN_INTERVAL_MIN               (uint16_t)(MSEC_TO_UNITS(7.5, UNIT_1_25_MS))    /**&amp;lt; Minimum acceptable connection interval, in units of 1.25 ms. */
#define CONN_INTERVAL_MAX               (uint16_t)(MSEC_TO_UNITS(500, UNIT_1_25_MS))    /**&amp;lt; Maximum acceptable connection interval, in units of 1.25 ms. */
#define CONN_SUP_TIMEOUT                (uint16_t)(MSEC_TO_UNITS(4000,  UNIT_10_MS))    /**&amp;lt; Connection supervisory timeout (4 seconds). */
#define SLAVE_LATENCY                   0                                               /**&amp;lt; Slave latency. */

#define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(5000)                       /**&amp;lt; Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(30000)                      /**&amp;lt; Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT    3                                           /**&amp;lt; Number of attempts before giving up the connection parameter negotiation. */

#define DEAD_BEEF                       0xDEADBEEF                                  /**&amp;lt; Value used as error code on stack dump, can be used to identify stack location on stack unwind. */



#define CONNECTED_LED                    BSP_BOARD_LED_0
#define TEST_LED                       BSP_BOARD_LED_1

#define APP_BLE_CONN_CFG_TAG            1                                           /**&amp;lt; A tag identifying the SoftDevice BLE configuration. */

#define NUS_SERVICE_UUID_TYPE           BLE_UUID_TYPE_VENDOR_BEGIN                  /**&amp;lt; UUID type for the Nordic UART Service (vendor specific). */

#define APP_BLE_OBSERVER_PRIO           3                                           /**&amp;lt; Application&amp;#39;s BLE observer priority. You shouldn&amp;#39;t need to modify this value. */

#define APP_ADV_INTERVAL                64                                          /**&amp;lt; The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */

#define APP_ADV_DURATION                18000                                       /**&amp;lt; The advertising duration (180 seconds) in units of 10 milliseconds. */

#define SAMPLE_TEST_DELAY  APP_TIMER_TICKS(8)  

extern uint32_t       *mp_block_to_fill;

BLE_ITS_DEF(m_its, NRF_SDH_BLE_TOTAL_LINK_COUNT);                                   /**&amp;lt; BLE NUS service instance. */
NRF_BLE_GATT_DEF(m_gatt);                                                           /**&amp;lt; GATT module instance. */
NRF_BLE_QWR_DEF(m_qwr);                                                             /**&amp;lt; Context for the Queued Write module.*/
BLE_ADVERTISING_DEF(m_advertising);                                                 /**&amp;lt; Advertising module instance. */

NRF_BLE_SCAN_DEF(m_scan);     


static uint8_t                          m_new_command_received = 0;
static uint8_t                          m_new_resolution, m_new_phy;
//static arducam_mini_2mp_init_t          m_camera_init;

static bool                             m_stream_mode_active = false;

static ble_its_ble_params_info_t        m_ble_params_info = {20, 50, 1, 1};

static uint16_t   m_conn_handle          = BLE_CONN_HANDLE_INVALID;                 /**&amp;lt; Handle of the current connection. */
static uint16_t   m_ble_its_max_data_len = BLE_GATT_ATT_MTU_DEFAULT - 3;            /**&amp;lt; Maximum length of data (in bytes) that can be transmitted to the peer by the Nordic UART service module. */
static ble_uuid_t m_adv_uuids[]          =                                          /**&amp;lt; Universally unique service identifier. */
{
    {BLE_UUID_ITS_SERVICE, NUS_SERVICE_UUID_TYPE}
};


board_role_t  m_board_role; 


			// command type
enum {CMD_NO_COMMAND = 0,
    	CMD_COMMAND,
	    CMD_SENSAMP,
		  CMD_DISABLE_MEAS, 
	    CMD_ENABLE_MEASURE,
	    CMD_SAMPLE_RATE,
      CMD_FLTER_CONFIG, 
      CMD_FILTER_TYPE, 
	    CMD_BYPASS, 
	    CMD_GET_BATT_VOLTAGE, 
	    CMD_GET_BATT_CURRENT, 
	    CMD_GET_BATT_PERCENT,
	    CMD_SAMPLES_XFER
};

static char const m_target_periph_name[] = DEVICE_NAME;

			static ble_uuid_t const m_nus_uuid =
{
    .uuid = BLE_UUID_NUS_SERVICE,
    .type = NUS_SERVICE_UUID_TYPE
};



#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(15, UNIT_1_25_MS)             /**&amp;lt; Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(15, UNIT_1_25_MS)             /**&amp;lt; Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
#define SLAVE_LATENCY                   0                                           /**&amp;lt; Slave latency. */
#define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)             /**&amp;lt; Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
#define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(5000)                       /**&amp;lt; Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(30000)                      /**&amp;lt; Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT    3                                           /**&amp;lt; Number of attempts before giving up the connection parameter negotiation. */


/**@brief Function for assert macro callback.
 *
 * @details This function will be called in case of an assert in the SoftDevice.
 *
 * @warning This handler is an example only and does not fit a final product. You need to analyse
 *          how your product is supposed to react in case of Assert.
 * @warning On assert from the SoftDevice, the system can only recover on reset.
 *
 * @param[in] line_num    Line number of the failing ASSERT call.
 * @param[in] p_file_name File name of the failing ASSERT call.
 */
void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name)
{
    app_error_handler(DEAD_BEEF, line_num, p_file_name);
}

/**@brief Function for initializing the timer module.
 */
static void timers_init(void)
{
    ret_code_t err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);
}



/**@brief Function for starting scanning. */
static void scan_start(void)
{
    ret_code_t ret;

    ret = nrf_ble_scan_start(&amp;amp;m_scan);
    APP_ERROR_CHECK(ret);

   // ret = bsp_indication_set(BSP_INDICATE_SCANNING);
  //  APP_ERROR_CHECK(ret);
}




/**@brief Function for initializing the timer.
 *
 * @details Initializes the timer module. This creates and starts application timers.
 */
static void timer_init(void)
{
    ret_code_t err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);
}





/**@brief Function for handling Queued Write module errors.
 *
 * @details A pointer to this function is passed to each service that may need to inform the
 *          application about an error.
 *
 * @param[in]   nrf_error   Error code that contains information about what went wrong.
 */
static void nrf_qwr_error_handler(uint32_t nrf_error)
{
    APP_ERROR_HANDLER(nrf_error);
}



static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    uint32_t err_code;

	
    switch (p_ble_evt-&amp;gt;header.evt_id)
    {
			DEBUG(&amp;quot;=&amp;gt; 0x%x&amp;quot;, p_ble_evt-&amp;gt;header.evt_id);
        case BLE_GAP_EVT_CONNECTED:
            DEBUG(&amp;quot;Connected&amp;quot;);
				    bsp_board_led_on(CONNECTED_LED);
//            err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
//            APP_ERROR_CHECK(err_code);
            m_conn_handle = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;
            err_code = nrf_ble_qwr_conn_handle_assign(&amp;amp;m_qwr, m_conn_handle);
            APP_ERROR_CHECK(err_code);
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            DEBUG(&amp;quot;Disconnected&amp;quot;);
				    bsp_board_led_off(CONNECTED_LED);
            // LED indication will be changed when advertising starts.
            m_conn_handle = BLE_CONN_HANDLE_INVALID;
            break;
				
	      case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
        {
            DEBUG(&amp;quot;PHY update request 2MBPS.&amp;quot;);
            ble_gap_phys_t const phys =
            {
                BLE_GAP_PHY_2MBPS,
                BLE_GAP_PHY_2MBPS,
            };
            err_code = sd_ble_gap_phy_update(p_ble_evt-&amp;gt;evt.gap_evt.conn_handle, &amp;amp;phys);
            APP_ERROR_CHECK(err_code);
        } break;			
				
        case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
            // Pairing not supported
            err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
            APP_ERROR_CHECK(err_code);
            break;

        case BLE_GATTS_EVT_SYS_ATTR_MISSING:
            // No system attributes have been stored.
            err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
            APP_ERROR_CHECK(err_code);
            break;

        case BLE_GATTC_EVT_TIMEOUT:
            // Disconnect on GATT Client timeout event.
            err_code = sd_ble_gap_disconnect(p_ble_evt-&amp;gt;evt.gattc_evt.conn_handle,
                                             BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
            APP_ERROR_CHECK(err_code);
            break;

        case BLE_GATTS_EVT_TIMEOUT:
            // Disconnect on GATT Server timeout event.
            err_code = sd_ble_gap_disconnect(p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle,
                                             BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
            APP_ERROR_CHECK(err_code);
            break;
				
				
        case BLE_GAP_EVT_CONN_PARAM_UPDATE:
        {
            uint16_t max_con_int = p_ble_evt-&amp;gt;evt.gap_evt.params.conn_param_update.conn_params.max_conn_interval;
            uint16_t min_con_int = p_ble_evt-&amp;gt;evt.gap_evt.params.conn_param_update.conn_params.min_conn_interval;

            m_ble_params_info.con_interval = max_con_int;
           // ble_its_ble_params_info_send(&amp;amp;m_its, &amp;amp;m_ble_params_info);
            DEBUG(&amp;quot;Con params updated: CI %i, %i&amp;quot;, (int)min_con_int, (int)max_con_int);
        } break;
            		
        case BLE_GAP_EVT_PHY_UPDATE:
            m_ble_params_info.tx_phy = p_ble_evt-&amp;gt;evt.gap_evt.params.phy_update.tx_phy;
            m_ble_params_info.rx_phy = p_ble_evt-&amp;gt;evt.gap_evt.params.phy_update.rx_phy;    
           // ble_its_ble_params_info_send(&amp;amp;m_its, &amp;amp;m_ble_params_info);
            DEBUG(&amp;quot;Phy update: %i, %i&amp;quot;, (int)m_ble_params_info.tx_phy, (int)m_ble_params_info.rx_phy);
            break;
        default:
            // No implementation needed.
            //DEBUG(&amp;quot;BLE event not handled by app: %i&amp;quot;, p_ble_evt-&amp;gt;header.evt_id);
            break;
    }
}



/**@brief Function for initializing the BLE stack.
 *
 * @details Initializes the SoftDevice and the BLE event interrupt.
 */
static void ble_stack_init(void)
{
    ret_code_t err_code;

    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);

    // Configure the BLE stack using the default settings.
    // Fetch the start address of the application RAM.
    uint32_t ram_start = 0;
    err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &amp;amp;ram_start);
    APP_ERROR_CHECK(err_code);

    // Enable BLE stack.
    err_code = nrf_sdh_ble_enable(&amp;amp;ram_start);
    APP_ERROR_CHECK(err_code);

    // Register a handler for BLE events.
    NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
}


/**@brief Function for the GAP initialization.
 *
 * @details This function will set up all the necessary GAP (Generic Access Profile) parameters of
 *          the device. It also sets the permissions and appearance.
 */
static void gap_params_init(void)
{
    uint32_t                err_code;
    ble_gap_conn_params_t   gap_conn_params;
    ble_gap_conn_sec_mode_t sec_mode;

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;sec_mode);

    err_code = sd_ble_gap_device_name_set(&amp;amp;sec_mode,
                                          (const uint8_t *) DEVICE_NAME,
                                          strlen(DEVICE_NAME));
    APP_ERROR_CHECK(err_code);

    memset(&amp;amp;gap_conn_params, 0, sizeof(gap_conn_params));

    gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
    gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
    gap_conn_params.slave_latency     = SLAVE_LATENCY;
    gap_conn_params.conn_sup_timeout  = CONN_SUP_TIMEOUT;

    err_code = sd_ble_gap_ppcp_set(&amp;amp;gap_conn_params);
    APP_ERROR_CHECK(err_code);
    
#if 0
    ble_gap_addr_t ble_address = {.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC,
                                  .addr_id_peer = 0,
                                  .addr = {0xC3,0x11,0x99,0x33,0x44,0xFF}};
    err_code = sd_ble_gap_addr_set(&amp;amp;ble_address);
    APP_ERROR_CHECK(err_code);
#endif
}


/**@brief Function for handling events from the GATT library. */
void gatt_evt_handler(nrf_ble_gatt_t * p_gatt, nrf_ble_gatt_evt_t const * p_evt)
{
    uint32_t data_length;
    if ((m_conn_handle == p_evt-&amp;gt;conn_handle) &amp;amp;&amp;amp; (p_evt-&amp;gt;evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED))
    {
        data_length = p_evt-&amp;gt;params.att_mtu_effective - OPCODE_LENGTH - HANDLE_LENGTH;
        //m_ble_params_info.mtu = m_ble_its_max_data_len;
        
        DEBUG(&amp;quot;gatt_event: ATT MTU is set to 0x%X (%d)&amp;quot;, data_length, data_length);
    }
    else if ((m_conn_handle == p_evt-&amp;gt;conn_handle) &amp;amp;&amp;amp; (p_evt-&amp;gt;evt_id == NRF_BLE_GATT_EVT_DATA_LENGTH_UPDATED))
    {
        data_length = p_evt-&amp;gt;params.att_mtu_effective - OPCODE_LENGTH - HANDLE_LENGTH - 4;
        m_ble_its_max_data_len = data_length;
        m_ble_params_info.mtu = m_ble_its_max_data_len;
        ble_its_ble_params_info_send(&amp;amp;m_its, &amp;amp;m_ble_params_info);
        
        DEBUG(&amp;quot;gatt_event: Data len is set to 0x%X (%d)&amp;quot;, data_length, data_length);
    }
    //NRF_LOG_DEBUG(&amp;quot;ATT MTU exchange completed. central 0x%x peripheral 0x%x&amp;quot;,
      //            p_gatt-&amp;gt;att_mtu_desired_central,
        //        p_gatt-&amp;gt;att_mtu_desired_periph);
}



/**@brief Function for initializing the GATT library. */
static void gatt_init(void)
{
    ret_code_t err_code = nrf_ble_gatt_init(&amp;amp;m_gatt, gatt_evt_handler);
    APP_ERROR_CHECK(err_code);
	
	    err_code = nrf_ble_gatt_att_mtu_periph_set(&amp;amp;m_gatt, NRF_SDH_BLE_GATT_MAX_MTU_SIZE);
    APP_ERROR_CHECK(err_code);
    
    err_code = nrf_ble_gatt_data_length_set(&amp;amp;m_gatt, BLE_CONN_HANDLE_INVALID, NRF_SDH_BLE_GAP_DATA_LENGTH);
    APP_ERROR_CHECK(err_code);
	
	
}


/**@brief Function for initializing power management.
 */
static void power_management_init(void)
{
    ret_code_t ret;
    ret = nrf_pwr_mgmt_init();
    APP_ERROR_CHECK(ret);
}



void conn_evt_len_ext_set(bool status)
{
    ret_code_t err_code;
    ble_opt_t  opt;

    memset(&amp;amp;opt, 0x00, sizeof(opt));
    opt.common_opt.conn_evt_ext.enable = status ? 1 : 0;

    err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &amp;amp;opt);
    APP_ERROR_CHECK(err_code);
}



void data_len_set(uint8_t value)
{
    ret_code_t err_code;
    err_code = nrf_ble_gatt_data_length_set(&amp;amp;m_gatt, BLE_CONN_HANDLE_INVALID, value);
    APP_ERROR_CHECK(err_code);

}



/**@brief Function for initializing the nrf log module.
 */
static void log_init(void)
{
    ret_code_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
}




/**@brief Function for handling an event from the Connection Parameters Module.
 *
 * @details This function will be called for all events in the Connection Parameters Module
 *          which are passed to the application.
 *
 * @note All this function does is to disconnect. This could have been done by simply setting
 *       the disconnect_on_fail config parameter, but instead we use the event handler
 *       mechanism to demonstrate its use.
 *
 * @param[in] p_evt  Event received from the Connection Parameters Module.
 */
static void on_conn_params_evt(ble_conn_params_evt_t * p_evt)
{
    switch(p_evt-&amp;gt;evt_type)
    {
        case BLE_CONN_PARAMS_EVT_SUCCEEDED:
            break;
            
        case BLE_CONN_PARAMS_EVT_FAILED:
            //err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
            //APP_ERROR_CHECK(err_code);
            NRF_LOG_ERROR(&amp;quot;Conn params failed. Keep the connection anyway..&amp;quot;);
            break;
    }
}


/**@brief Function for handling errors from the Connection Parameters module.
 *
 * @param[in] nrf_error  Error code containing information about what went wrong.
 */
static void conn_params_error_handler(uint32_t nrf_error)
{
    APP_ERROR_HANDLER(nrf_error);
}


/**@brief Function for initializing the Connection Parameters module.
 */
static void conn_params_init(void)
{
    uint32_t               err_code;
    ble_conn_params_init_t cp_init;

    memset(&amp;amp;cp_init, 0, sizeof(cp_init));

    cp_init.p_conn_params                  = NULL;
    cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
    cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
    cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
    cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
    cp_init.disconnect_on_fail             = false;
    cp_init.evt_handler                    = on_conn_params_evt;
    cp_init.error_handler                  = conn_params_error_handler;

    err_code = ble_conn_params_init(&amp;amp;cp_init);
    APP_ERROR_CHECK(err_code);
}


/**@brief Function for starting advertising.
 */
static void advertising_start(void)
{
    uint32_t err_code = ble_advertising_start(&amp;amp;m_advertising, BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
}



/**@brief Function for handling advertising events.
 *
 * @details This function will be called for advertising events which are passed to the application.
 *
 * @param[in] ble_adv_evt  Advertising event.
 */
static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
{
    uint32_t err_code;

    switch (ble_adv_evt)
    {
        case BLE_ADV_EVT_FAST:
          //  err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
         //   APP_ERROR_CHECK(err_code);
            break;
        case BLE_ADV_EVT_IDLE:
            DEBUG(&amp;quot;BLE_ADV_EVT_IDLE...&amp;quot;);
            err_code = ble_advertising_start(&amp;amp;m_advertising, BLE_ADV_MODE_FAST);
            APP_ERROR_CHECK(err_code);
            break;
        default:
            break;
    }
}



/**@brief Function for initializing the Advertising functionality.
 */
static void advertising_init(void)
{
    uint32_t               err_code;
    ble_advertising_init_t init;

    memset(&amp;amp;init, 0, sizeof(init));

    init.advdata.name_type          = BLE_ADVDATA_FULL_NAME;
    init.advdata.include_appearance = false;
    init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;

    init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.srdata.uuids_complete.p_uuids  = m_adv_uuids;

    init.config.ble_adv_fast_enabled  = true;
    init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
    init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&amp;amp;m_advertising, &amp;amp;init);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&amp;amp;m_advertising, APP_BLE_CONN_CFG_TAG);
}




static void sample_delay_timeout_handler(void * p_context)
{
 uint8_t arraytest[200]; 
	bsp_board_led_invert(TEST_LED);
	ble_its_string_send(&amp;amp;m_its, arraytest, 64);
}


/**@brief   Function for handling app_uart events.
 *
 * @details This function will receive a single character from the app_uart module and append it to
 *          a string. The string will be be sent over BLE when the last character received was a
 *          &amp;#39;new line&amp;#39; &amp;#39;\n&amp;#39; (hex 0x0A) or if the string has reached the maximum data length.
 */
/**@snippet [Handling the data received over UART] */
void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[100];
    static uint8_t index = 0;
	  uint8_t file_data[10]= {1,3,5,2,35,3,2,14,225,45};
  //  uint32_t       err_code;

    switch (p_event-&amp;gt;evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));
            index++;

            if ((data_array[index - 1] == &amp;#39;\n&amp;#39;) || (data_array[index - 1] == &amp;#39;\r&amp;#39;))
            {
							 if (index &amp;gt; 1)
                {
                  
									   printf(&amp;quot;UART Read(  %s )\n&amp;quot;,data_array);
									
										 if( (strstr(data_array, &amp;quot;SCAN&amp;quot;) != NULL) )											 
											{			
												//  scan_start();
																	
											}			
											
										  if( (strstr(data_array, &amp;quot;DISCONNECT&amp;quot;) != NULL) )											 
											{			
												          ret_code_t err_code;
												err_code = sd_ble_gap_disconnect(m_advertising.adv_handle , BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);

												if (err_code != NRF_SUCCESS)
												{
														DEBUG(&amp;quot;sd_ble_gap_disconnect() failed: 0x%0x.&amp;quot;, err_code);
                            }
																	
											}	

										 if( (strstr(data_array, &amp;quot;TESTXFER&amp;quot;) != NULL) )											 
											{			
												 DEBUG(&amp;quot;Xfert file.&amp;quot;);
												  ble_its_string_send(&amp;amp;m_its, &amp;amp;file_data[0], sizeof(file_data));
																	
											}	

	
										 if( (strstr(data_array, &amp;quot;FILE&amp;quot;) != NULL) )											 
											{			
												  ble_its_string_send(&amp;amp;m_its, data_array, strlen(data_array));
																	
											}												

											
										if( (strstr(data_array, &amp;quot;START&amp;quot;) != NULL) )											 
											{			
												  	app_timer_start(m_sample_delay_timer_id, SAMPLE_TEST_DELAY, NULL);	
																	
											}	
											
//										else if( ( m_board_role == SDT_SENSOR_ROLE &amp;amp;&amp;amp; (strstr(data_array, &amp;quot;START&amp;quot;) != NULL) ))
//											{
//												//test_begin();		 			
//											}			

//										else if( ( m_board_role == SDT_RECIEVER_ROLE &amp;amp;&amp;amp; (strstr(data_array, &amp;quot;TESTXFER&amp;quot;) != NULL) ))
//											{
//												//reciever_params_info_send(&amp;amp;m_amts); 			
//											}		
											
											
											
											
//										else if( strstr(data_array, &amp;quot;STOP&amp;quot;) != NULL)										
//											stop_transmission(); 
										
                }

                index = 0;
							
							      //  m_run_test = true;
                   //  test_run();
            }
            break;

        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
            break;

        default:
            break;
    }
}




/**@snippet [Handling the data received over UART] */


/**@brief  Function for initializing the UART module.
 */
/**@snippet [UART Initialization] */
static void uart_init(void)
{
    uint32_t                     err_code;
    app_uart_comm_params_t const comm_params =
    {
        .rx_pin_no    = RX_PIN_NUMBER,
        .tx_pin_no    = TX_PIN_NUMBER,
        .rts_pin_no   = RTS_PIN_NUMBER,
        .cts_pin_no   = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity   = false,
#if defined (UART_PRESENT)
        .baud_rate    = NRF_UART_BAUDRATE_115200
#else
        .baud_rate    = NRF_UARTE_BAUDRATE_115200
#endif
    };

    APP_UART_FIFO_INIT(&amp;amp;comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_event_handle,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);
    APP_ERROR_CHECK(err_code);
}
/**@snippet [UART Initialization] */




/**@brief Function for handling the data from the ITS Service.
 *
 * @details This function will process the data received from the ITS BLE Service.
 *
 * @param[in] p_its    ITS Service structure.
 * @param[in] p_data   Data received.
 * @param[in] length   Length of the data.
 */
/**@snippet [Handling the data received over BLE] */
static void its_data_handler(ble_its_t * p_its, uint8_t const * p_data, uint16_t length)
{
	bsp_board_led_invert(TEST_LED);
	//DEBUG(&amp;quot;Recieve %d, %d\n&amp;quot;, p_data[0],length); 
    switch(p_data[0])
    {
//        // Take picture
//        case APP_CMD_SINGLE_CAPTURE:
//        case APP_CMD_SEND_BLE_PARAMS:
//            m_new_command_received = p_data[0];
//            break;
//        
//        case APP_CMD_START_STREAM:
//            m_stream_mode_active = true;
//            m_new_command_received = p_data[0];
//            break;

//        case APP_CMD_STOP_STREAM:
//            m_stream_mode_active = false;
//            m_new_command_received = p_data[0];
//            break;
//        
//        case APP_CMD_CHANGE_RESOLUTION:
//            m_new_command_received = APP_CMD_CHANGE_RESOLUTION;
//            m_new_resolution = p_data[1];
//            break;
//        
//        case APP_CMD_CHANGE_PHY:
//            m_new_command_received = APP_CMD_CHANGE_PHY;
//            m_new_phy = p_data[1];
//            break;
//        
//        default: 
//            NRF_LOG_ERROR(&amp;quot;Unknown command!!&amp;quot;);
//            break;
    }
}
/**@snippet [Handling the data received over BLE] */



/**@brief Function for initializing services that will be used by the application.
 */
static void services_init(void)
{
    uint32_t           err_code;
    ble_its_init_t     its_init;
    nrf_ble_qwr_init_t qwr_init = {0};

    // Initialize Queued Write Module.
    qwr_init.error_handler = nrf_qwr_error_handler;

    err_code = nrf_ble_qwr_init(&amp;amp;m_qwr, &amp;amp;qwr_init);
    APP_ERROR_CHECK(err_code);

    // Initialize ITS.
    memset(&amp;amp;its_init, 0, sizeof(its_init));

    its_init.data_handler = its_data_handler;

    err_code = ble_its_init(&amp;amp;m_its, &amp;amp;its_init);
    APP_ERROR_CHECK(err_code);
}

/**@brief Function for initializing the LEDs.
 *
 * @details Initializes all LEDs used by the application.
 */
static void leds_init(void)
{
    bsp_board_init(BSP_INIT_LEDS);
}

/**@brief Function for handling the idle state (main loop).
 *
 * @details If there is no pending log operation, then sleep until next the next event occurs.
 */
static void idle_state_handle(void)
{
//    while(NRF_LOG_PROCESS());
//    sd_app_evt_wait();
	    UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());
    nrf_pwr_mgmt_run();
	
}



int main(void)
{
    // Initialize.
    ble_gap_phys_t gap_phys_settings;		
	  uart_init();
   // log_init();
    leds_init();
    timer_init();
    //counter_init();
	  gpio_init(); 
	  m_board_role = get_sdt_boardrole(); 
   // buttons_init();
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
	  services_init();
	  advertising_init(); 
	  conn_params_init(); 
	  sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
	
	//   scan_init();  // RECIEVER
	
	advertising_start(); 
	
	DEBUG(&amp;quot;Start test !!!&amp;quot;); 
	
 app_timer_create(&amp;amp;m_sample_delay_timer_id,
                            APP_TIMER_MODE_REPEATED,
                            sample_delay_timeout_handler);
	



										
										
	//  sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);  
   
    for (;;)
    {
	
			idle_state_handle();
        
			
			
    }
}

/**
 * @}
 */
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/thread/200006?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2019 10:56:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d89d708-0e40-4d55-996a-db17fe4d8b2f</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;So if your question is now resolved, please verify the answer:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/5187._5F00_Verify_2D00_answer_2D00_nordic.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/thread/200003?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2019 10:51:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf3c64bc-e8d0-42d7-a262-0ecd7843a839</guid><dc:creator>merlin chendjou</dc:creator><description>&lt;p&gt;Dear sir,&amp;nbsp;&lt;/p&gt;
&lt;pre class="tw-data-text tw-ta tw-text-small" id="tw-target-text" dir="ltr"&gt;&lt;span lang="en"&gt;Please do not consider my last message.
I found the error and corrected.&lt;br /&gt;&lt;br /&gt;Thanks, &lt;/span&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/thread/199878?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2019 17:43:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb2671ed-18e0-4cf7-8c54-250c4a2c06d3</guid><dc:creator>merlin chendjou</dc:creator><description>&lt;p&gt;Dear Sir,&lt;/p&gt;
&lt;p&gt;I thank you for this remark. I can indeed see that&amp;nbsp; SAADC Callback is called after 100 samples since SAMPLE_IN_BUFFER&amp;nbsp; is set to 100.&lt;/p&gt;
&lt;p&gt;To make sure that I get into the callback, I toggle a pin out of the chip to ensure that the duration of taking measurements is constant and therefore my samples are synchronized.&lt;/p&gt;
&lt;p&gt;If I activate a Bluetooth transmission in parallel, during the transfer, I can notice a timing error in the SAADC Callback . There is therefore an error in the discretization of my signal.&lt;br /&gt;How can I set a priority on my ADC timer or correct the timing problem when the handles on Bluetooth events are called ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/thread/198493?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2019 13:32:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c72b3bb7-b0bf-48e1-97a0-0012af53278b</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;In your callback:&lt;br /&gt;&lt;br /&gt;// set buffers&lt;br /&gt; err_code = nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, &lt;strong&gt;1&lt;/strong&gt;);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt;&lt;br /&gt;Set the length to&amp;nbsp;SAMPLES_IN_BUFFER and you should be good.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/thread/197944?ContentTypeID=1</link><pubDate>Thu, 11 Jul 2019 18:51:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6b11523-52dc-47e0-a113-32d9254be016</guid><dc:creator>merlin chendjou</dc:creator><description>&lt;p&gt;&lt;span&gt;I understood that I could initialize the Buffer&amp;nbsp;size to 200 samples by changing define SAMPLES_IN_BUFFER. What I do not understand is how to configure my sampling frequency at 16kHz to have a Callback every 12.5ms.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In order to perform the tests, I set the sampling time to 125us (8kHz) with a SAMPLES_IN_BUFFER 200. According to the code below, I hoped that my Callback would be called every 25mS. I can see that my Callback is called every 125uS and I do not understand.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please see the source code below :&amp;nbsp;&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;#define SAADC_SAMPLE_RATE		        125                                         /**&amp;lt; SAADC sample rate in us. */      
#define SAMPLES_IN_BUFFER 200 


void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
    if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)
    {
        ret_code_t err_code;
        float adc_value,adc_value_filered;
        uint8_t value[2];
        uint8_t bytes_to_send;
     
        // set buffers
        err_code = nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, 1);
        APP_ERROR_CHECK(err_code);
						
			  bsp_board_led_invert(PROGRESS_LED);
 
    }
}



void saadc_sampling_event_init(void)
{
    ret_code_t err_code;
    err_code = nrf_drv_ppi_init();
    APP_ERROR_CHECK(err_code);
    
    nrf_drv_timer_config_t timer_config = NRF_DRV_TIMER_DEFAULT_CONFIG;
  //  timer_config.frequency = NRF_TIMER_FREQ_31250Hz;
	  timer_config.frequency = NRF_TIMER_FREQ_1MHz;
    err_code = nrf_drv_timer_init(&amp;amp;m_timer, &amp;amp;timer_config, timer_handler);
    APP_ERROR_CHECK(err_code);

    /* setup m_timer for compare event */
    uint32_t ticks = nrf_drv_timer_us_to_ticks(&amp;amp;m_timer,SAADC_SAMPLE_RATE);
    nrf_drv_timer_extended_compare(&amp;amp;m_timer, NRF_TIMER_CC_CHANNEL0, ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
    nrf_drv_timer_enable(&amp;amp;m_timer);

    uint32_t timer_compare_event_addr = nrf_drv_timer_compare_event_address_get(&amp;amp;m_timer, NRF_TIMER_CC_CHANNEL0);
    uint32_t saadc_sample_event_addr = nrf_drv_saadc_sample_task_get();

    /* setup ppi channel so that timer compare event is triggering sample task in SAADC */
    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_event_addr);
    APP_ERROR_CHECK(err_code);
}


void saadc_init(void)
{
    ret_code_t err_code;
    nrf_drv_saadc_config_t saadc_config = NRF_DRV_SAADC_DEFAULT_CONFIG;
    saadc_config.resolution = NRF_SAADC_RESOLUTION_12BIT;
	

    err_code = nrf_drv_saadc_init(&amp;amp;saadc_config, saadc_callback);
    APP_ERROR_CHECK(err_code);

	    //Configure SAADC channel
    nrf_saadc_channel_config_t config =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);                           //Disable pulldown resistor on the input pin
    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;config);
    APP_ERROR_CHECK(err_code);

	
    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0],SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);   
    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1],SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);
}


void saadc_sampling_event_enable(void)
{
    ret_code_t err_code = nrf_drv_ppi_channel_enable(m_ppi_channel);
    APP_ERROR_CHECK(err_code);
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/thread/197802?ContentTypeID=1</link><pubDate>Thu, 11 Jul 2019 11:11:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d18f3a3b-6caf-46cb-a316-d8224cc50483</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;If you just set your buffer size to 200 samples, you&amp;#39;ll get a callback once those are done. The saadc example uses the define SAMPLES_IN_BUFFER or something similar to set the buffer sizes.&amp;nbsp;&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: Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/thread/197617?ContentTypeID=1</link><pubDate>Wed, 10 Jul 2019 12:18:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3a0b95c-70c7-44ed-8fb7-aa7192b02b89</guid><dc:creator>merlin chendjou</dc:creator><description>&lt;p&gt;&lt;span&gt;Hello, &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for your reply.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I changed the callback time to a few milliseconds and the problem is solved. I just did a test by changing the Callback timer to 10ms and it works. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If I want to sample my signal at 16ksps, so with a buffer of 200 samples I can set a Callback every 12.5ms. Can you help me configure my timer and the SAADC ?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/thread/197553?ContentTypeID=1</link><pubDate>Wed, 10 Jul 2019 09:17:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d5c2eb5-1a5d-44a1-ad33-84f69f8c8ca9</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;How to properly post source code:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/1732._5F00_Insert-Code-_2D00_-Nordic.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/thread/197518?ContentTypeID=1</link><pubDate>Wed, 10 Jul 2019 07:53:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3da440bf-4ca3-4543-98b5-a03e6c21b94a</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;I have not found a root cause, but I did find something that will be an issue.&lt;br /&gt;&lt;br /&gt;You&amp;#39;re using SAADC buffer sizes of 1, ie. one sample taken and processed every 80µs, and that&amp;#39;s not possible with a BLE stack running. You need to use larger buffer sizes for your ADC sampling and process them far less often.&amp;nbsp;&lt;br /&gt;What will happen now is that the SoftDevice will block the SAADC driver&amp;#39;s IRQ from executing whenever there&amp;#39;s some BLE activity or stack processing to be done, and your SAADC sampling will halt.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I suggest you double buffer your SAADC buffers, like our example does, and choose a size so that you will get a callback every few milliseconds (the longer the better).&amp;nbsp;&lt;br /&gt;&lt;br /&gt;This issue might be related to your original issue, what IRQ priority have you set the SAADC driver to use?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/thread/197447?ContentTypeID=1</link><pubDate>Tue, 09 Jul 2019 15:46:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:813fb221-1f8f-4cfb-93d9-5bd8d9ed8041</guid><dc:creator>merlin chendjou</dc:creator><description>&lt;p&gt;&lt;span&gt;when the event to activate the timer for sampling SAADC is enabled (saadc_sampling_event_enable() ) ,&amp;nbsp;AMT server event handler is no longer executes. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You must disable the timer event for&amp;nbsp;sampling SAADC, so&amp;nbsp; the AMT server event&amp;nbsp; works properly.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&amp;nbsp;&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: Try to transfert ADC sampling signal by BLE.</title><link>https://devzone.nordicsemi.com/thread/197373?ContentTypeID=1</link><pubDate>Tue, 09 Jul 2019 12:20:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b668621-a722-4ab3-ae21-fef97090ea66</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;&amp;quot;If I enable sampling and data transfer by BLE, the Bluetooth stack no longer works (the pairing does not run). I tried to use SAADC sampling using other Timers and the problem is not solved.I notice that the timer activation generates a conflict&amp;nbsp;with&amp;nbsp;the bluetooth stack.&amp;quot;&lt;br /&gt;&lt;br /&gt;We need some details&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>