<?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(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92949/saadc-two-channel-differencial-sampling-by-external-62-5khz-clock-interrupt</link><description>I am developing a product using the nRF52840. I am currently running into a difficult problem. I inquired about it 2 years ago, but it has not been resolved. 
 I need to process Two Channel (Diffrencial) type saadc by using an external 62.5Khz interrupt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 31 Oct 2022 08:58:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92949/saadc-two-channel-differencial-sampling-by-external-62-5khz-clock-interrupt" /><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/393168?ContentTypeID=1</link><pubDate>Mon, 31 Oct 2022 08:58:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e5a15ab-ab6f-4c4a-8a34-31045457e1d4</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I believe it looks right, the generic formula is found here:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html#saadc_digital_output"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html#saadc_digital_output&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/392981?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 10:02:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a060dbee-c0cf-465d-895c-355ed48314d3</guid><dc:creator>ParanBada</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;I inquired about the voltage calculation formula for differential sampling above.&lt;br /&gt;I look forward to your reply.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;SunBae Yim.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/392826?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2022 12:35:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e68b15d7-1aac-4c76-b53a-bf57cc0571c3</guid><dc:creator>ParanBada</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Differential ADC sampling:&lt;br /&gt;Find the difference by reading the P and N channels. Is that right? (VALUE = P - N)&lt;/p&gt;
&lt;p&gt;The same formula is used as follows.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define SIMPLE_REF_VOLTAGE_IN_MILLIVOLTS   		600.0f                                     /**&amp;lt; Reference voltage (in milli volts) used by ADC while doing conversion. */
#define SIMPLE_PRE_SCALING_COMPENSATION    		6.0f                                       /**&amp;lt; The ADC is configured to use VDD with 1/3 prescaling as input. And hence the result of conversion is to be multiplied by 3 to get the actual value of the battery voltage.*/
#define SIMPLE_ADC_RES_10BITS             		1024.0f                                    /**&amp;lt; Maximum digital value for 10-bit ADC conversion. */

/**@brief Macro to convert the result of ADC conversion in millivolts.
 *
 * @param[in]  ADC_VALUE   ADC result.
 *
 * @retval     Result converted to millivolts.
 */
#define SIMPLE_VOUT_IN_MILLI_VOLTS(ADC_VALUE)\
				((((ADC_VALUE) * SIMPLE_REF_VOLTAGE_IN_MILLIVOLTS) / SIMPLE_ADC_RES_10BITS) * SIMPLE_PRE_SCALING_COMPENSATION)
&lt;/pre&gt;&lt;br /&gt;Please check if this formula can also be used for DIFFRENTIAL.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;SunBae Yim.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/392784?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2022 10:02:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b43890a-90f9-4dd6-8870-e26a9f5b304f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="ParanBada0"]Does the differential read half the voltage?[/quote]
&lt;p&gt;No, it should not. I suggest for test that you try with a different source (for instance with less impedance), and possible try to increase the acquisition time, ref:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/392778?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2022 09:37:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40af9d0b-d9cd-4060-8b13-1b38bfa703a3</guid><dc:creator>ParanBada</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I implemented ADC sampling with a differential like the source code above, and converted it into a voltage value using the formula.&lt;br /&gt;However, the voltage value is only half of the actual measured value.&lt;/p&gt;
&lt;p&gt;Does the differential read half the voltage? Or do I have to change the formula?&lt;/p&gt;
&lt;p&gt;In differential sampling, half the voltage is output, how can I solve it?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;SunBae Yim.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/392635?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2022 13:17:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fdfa6c4-a598-4b0a-826b-39752b79dd30</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi again,&lt;/p&gt;
&lt;p&gt;Looking at the example you shared on your google drive, these are the two things you can change.&lt;/p&gt;
&lt;p&gt;In&amp;nbsp;simple_irq_init() use:&lt;br /&gt;err_code = nrfx_gpiote_in_init(ADA2200_SYNCO_PIN, &amp;amp;in_config, &lt;span style="background-color:rgba(0, 255, 0, 1);"&gt;NULL&lt;/span&gt;);&lt;/p&gt;
&lt;p&gt;In addition change to:&lt;br /&gt;#define SIM_SAMPLES_IN_BUFFER &lt;span&gt; &lt;/span&gt;&lt;span style="background-color:rgba(0, 255, 0, 1);"&gt;10 // or maybe even higher like 100&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;At least then it seems to trigger&amp;nbsp;simple_voltage_handler() every 10 or 100 samples here.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/392574?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2022 10:32:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab7edb59-2d41-4253-b3a8-2c4e331a7446</guid><dc:creator>ParanBada</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;I have a tight schedule these days, so it&amp;#39;s very difficult. I need your help.&lt;br /&gt;I inquired about the PPI source code above.&lt;br /&gt;Please review my source code and give me an answer.&lt;br /&gt;I took your advice and blocked the interrupt.&lt;br /&gt;simple_voltage_handler() function is not executed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/392436?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2022 14:30:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:993cb374-ca2b-425a-901d-c9b30e18eb8d</guid><dc:creator>ParanBada</dc:creator><description>&lt;p&gt;I add the missing figure in the above post as follows:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:771px;max-width:726px;" alt=" " height="771" src="https://devzone.nordicsemi.com/resized-image/__size/1452x1542/__key/communityserver-discussions-components-files/4/2043._F8ADBCB9_1.png" width="726" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/392433?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2022 14:26:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:745d88c9-21e2-4c07-b62b-2a9c71f73269</guid><dc:creator>ParanBada</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You said:&lt;br /&gt;&amp;quot; &lt;span&gt;Even though you are sampling this at 62.5kHz, you should not need to execute an MCU interrupt at this interval. Much of the point of having PPI and EasyDMA is to offload the MCU for the real-time requirements,......&lt;/span&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;So I followed your advice and deleted the [interrupt function] as in the following code.&lt;br /&gt;By the way, simple_voltage_handler() is not called. Why?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*******************************************************************************
 * @file	meas_pd_voltage.c
 * @author	CandyPops Co.
 * @version	V1.0.0
 * @date	2022-09-05
 * @brief   
 ******************************************************************************/

#include &amp;quot;sdk_common.h&amp;quot;
			
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_drv_saadc.h&amp;quot;
#include &amp;quot;nrfx_gpiote.h&amp;quot;
#include &amp;quot;nrf_drv_gpiote.h&amp;quot;
#include &amp;quot;nrf_drv_ppi.h&amp;quot;
#include &amp;quot;nrf_drv_timer.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;

#include &amp;quot;meas_pd_voltage_simple.h&amp;quot;


#define PD_REF_VOLTAGE_IN_MILLIVOLTS   		600.0f                                     /**&amp;lt; Reference voltage (in milli volts) used by ADC while doing conversion. */
#define PD_PRE_SCALING_COMPENSATION    		6.0f                                       /**&amp;lt; The ADC is configured to use VDD with 1/3 prescaling as input. And hence the result of conversion is to be multiplied by 3 to get the actual value of the battery voltage.*/
#define PD_ADC_RES_10BITS             		1024.0f                                    /**&amp;lt; Maximum digital value for 10-bit ADC conversion. */

/**@brief Macro to convert the result of ADC conversion in millivolts.
 *
 * @param[in]  ADC_VALUE   ADC result.
 *
 * @retval     Result converted to millivolts.
 */
#define PD_VOUT_IN_MILLI_VOLTS(ADC_VALUE)\
				((((ADC_VALUE) * PD_REF_VOLTAGE_IN_MILLIVOLTS) / PD_ADC_RES_10BITS) * PD_PRE_SCALING_COMPENSATION)

#define SIM_SAMPLES_IN_BUFFER 		10

static nrf_saadc_value_t pd_adc_buf[2][SIM_SAMPLES_IN_BUFFER];
float pd_voltage_in_milli_volts = 0;
bool  pd_adc_simple_start	= false;





/** @brief Macro for setting @ref nrfx_saadc_config_t to default settings. */
#define PD_NRFX_SAADC_DEFAULT_CONFIG                                            \
{                                                                               \
    .resolution         = (nrf_saadc_resolution_t)NRFX_SAADC_CONFIG_RESOLUTION, \
    .oversample         = (nrf_saadc_oversample_t)NRFX_SAADC_CONFIG_OVERSAMPLE, \
    .interrupt_priority = NRFX_SAADC_CONFIG_IRQ_PRIORITY,                       \
    .low_power_mode     = NRFX_SAADC_CONFIG_LP_MODE                             \
}
/* Resolution is 10bits */
/* Over Sampling Disabled */
/* Interrupt Priority is 0(Highest) */
/* Low Power Mode is Disabled */




/**
 * @brief Macro for setting @ref nrf_saadc_channel_config_t to default settings
 *        in differential mode.
 *
 * @param PIN_P Positive analog input.
 * @param PIN_N Negative analog input.
 */
#define PD_NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(PIN_P, PIN_N) \
{                                                                       \
    .resistor_p = NRF_SAADC_RESISTOR_DISABLED,                          \
    .resistor_n = NRF_SAADC_RESISTOR_DISABLED,                          \
    .gain       = NRF_SAADC_GAIN1_6,                                    \
    .reference  = NRF_SAADC_REFERENCE_INTERNAL,                         \
    .acq_time   = NRF_SAADC_ACQTIME_3US,                                \
    .mode       = NRF_SAADC_MODE_DIFFERENTIAL,                          \
    .burst      = NRF_SAADC_BURST_DISABLED,                             \
    .pin_p      = (nrf_saadc_input_t)(PIN_P),                           \
    .pin_n      = (nrf_saadc_input_t)(PIN_N)                            \
}


#define PD_ADC_CNT	8
uint8_t SIM_IRQ_NO = 8;

uint32_t sim_call_cnt 		= 0;
uint32_t sim_ans_cnt 		= 0;

float pd_voltage_buff[110] = {0.0f,}; /* For Cycle-8, Cycle-16, Cycle-24, Cycle-32 */ 
uint8_t	pd_voltage_buff_idx = 0;

static nrf_ppi_channel_t	m_ppi_channel;


void simple_ppi_init(void)
{
    ret_code_t err_code;

	printf(&amp;quot;simple_ppi_init\r\n&amp;quot;);

    err_code = nrf_drv_ppi_init();
    APP_ERROR_CHECK(err_code);

    uint32_t gpiote_event_addr = nrf_drv_gpiote_in_event_addr_get(ADA2200_SYNCO_PIN);	
    uint32_t saadc_sample_task_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,
                                          gpiote_event_addr,
                                          saadc_sample_task_addr);
    APP_ERROR_CHECK(err_code);
}


void simple_ppi_uninit(void)
{
    ret_code_t err_code;
	printf(&amp;quot;simple_ppi_uninit\r\n&amp;quot;);

    err_code = nrf_drv_ppi_uninit();
    APP_ERROR_CHECK(err_code);
}


void simple_sampling_event_enable(void)
{
	printf(&amp;quot;simple_sampling_event_enable\r\n&amp;quot;);

    ret_code_t err_code = nrf_drv_ppi_channel_enable(m_ppi_channel);
    APP_ERROR_CHECK(err_code);

	/////////////////////////////////////////////
	nrf_delay_us(500);
	nrf_drv_gpiote_in_event_enable(ADA2200_SYNCO_PIN, true);
	nrf_delay_us(500);
	/////////////////////////////////////////////
}


void simple_sampling_event_disable(void)
{
	printf(&amp;quot;simple_sampling_event_disable\r\n&amp;quot;);

	nrf_drv_gpiote_in_event_disable(ADA2200_SYNCO_PIN);

	ret_code_t err_code = nrf_drv_ppi_channel_disable(m_ppi_channel);
	APP_ERROR_CHECK(err_code);
}


/**@brief Function for handling the ADC interrupt.
 *
 * @details  This function will fetch the conversion result from the ADC, convert the value into
 *           percentage and send it to peer.
 */
static void simple_voltage_handler(nrf_drv_saadc_evt_t const * p_event)	/* PD Voltage reading */
{
	printf(&amp;quot;p\r\n&amp;quot;);

    if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)
    {	
		nrf_gpio_pin_set(ANS_INT_26);
		nrf_gpio_pin_clear(ANS_INT_26);

	   	sim_ans_cnt++;
	
        nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, SIM_SAMPLES_IN_BUFFER);

		pd_voltage_in_milli_volts = PD_VOUT_IN_MILLI_VOLTS(p_event-&amp;gt;data.done.p_buffer[0]);

		pd_voltage_buff[pd_voltage_buff_idx] = pd_voltage_in_milli_volts;
		pd_voltage_buff_idx++;

		if(sim_call_cnt == 100) {
			pd_adc_simple_start = false;

			simple_mesurement_stop();


			printf(&amp;quot;iDx = %d \r\n&amp;quot;, pd_voltage_buff_idx);
			printf(&amp;quot;sim_call_cnt=%d, sim_ans_cnt=%d\r\n&amp;quot;, sim_call_cnt, sim_ans_cnt);
			
			for(uint8_t i = 0; i &amp;lt; 110; i++) {
				printf(&amp;quot; %f &amp;quot;, pd_voltage_buff[i]);
			}
			printf(&amp;quot;\r\n === TEST END === \r\n\r\n&amp;quot;);

			

			memset(pd_voltage_buff, 0, 110);
			pd_voltage_buff_idx = 0;

			sim_call_cnt		= 0;
			sim_ans_cnt			= 0;
			pd_voltage_buff_idx	= 0;
		}
    }
}


void simple_adc_init(void)
{
	printf(&amp;quot;simple_adc_init\r\n&amp;quot;);


	nrfx_saadc_config_t default_config = PD_NRFX_SAADC_DEFAULT_CONFIG;

	nrf_saadc_channel_config_t config =
	PD_NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(NRF_SAADC_INPUT_AIN0, NRF_SAADC_INPUT_AIN1);

	
	ret_code_t err_code = nrf_drv_saadc_init(&amp;amp;default_config, simple_voltage_handler);
	APP_ERROR_CHECK(err_code);

	err_code = nrf_drv_saadc_channel_init(0, &amp;amp;config);
	APP_ERROR_CHECK(err_code);

	err_code = nrf_drv_saadc_buffer_convert(pd_adc_buf[0], SIM_SAMPLES_IN_BUFFER);
	APP_ERROR_CHECK(err_code);

	err_code = nrf_drv_saadc_buffer_convert(pd_adc_buf[1], SIM_SAMPLES_IN_BUFFER);
	APP_ERROR_CHECK(err_code);	
}


void simple_adc_uninit(void)
{
	printf(&amp;quot;simple_adc_uninit\r\n&amp;quot;);

	nrf_drv_saadc_uninit();
	nrf_drv_saadc_channel_uninit(0);
}


//static void simple_interrupt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
//{
//	if(pd_adc_simple_start == true) {
//		sim_call_cnt++;
//
//		//nrf_gpio_pin_set(CALL_INT_18);
//		//nrf_gpio_pin_clear(CALL_INT_18);
//
////		if(sim_call_cnt == 100) {
////			pd_adc_simple_start = false;
////
////			simple_mesurement_stop();
////
////
////			printf(&amp;quot;iDx = %d \r\n&amp;quot;, pd_voltage_buff_idx);
////			printf(&amp;quot;sim_call_cnt=%d, sim_ans_cnt=%d\r\n&amp;quot;, sim_call_cnt, sim_ans_cnt);
////			
////			for(uint8_t i = 0; i &amp;lt; 110; i++) {
////				printf(&amp;quot; %f &amp;quot;, pd_voltage_buff[i]);
////			}
////			printf(&amp;quot;\r\n === TEST END === \r\n\r\n&amp;quot;);
////
////			
////
////			memset(pd_voltage_buff, 0, 110);
////			pd_voltage_buff_idx = 0;
////
////			sim_call_cnt		= 0;
////			sim_ans_cnt			= 0;
////			pd_voltage_buff_idx	= 0;
////		}
//	}
//}	


//void simple_irq_init(void){
//    ret_code_t err_code;
//
//	printf(&amp;quot;simple_irq_init\r\n&amp;quot;);
//
//	/* Initialize int pin */
//	if (!nrfx_gpiote_is_init())
//	{
//	  err_code = nrfx_gpiote_init();
//	  APP_ERROR_CHECK(err_code);
//	}
//
//    nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
//    in_config.pull = NRF_GPIO_PIN_PULLDOWN;
//
//    err_code = nrfx_gpiote_in_init(ADA2200_SYNCO_PIN, &amp;amp;in_config, simple_interrupt_handler);
//    APP_ERROR_CHECK(err_code);
//
//    nrfx_gpiote_in_event_enable(ADA2200_SYNCO_PIN, true);
//}


//void simple_irq_uninit(void){
//	printf(&amp;quot;pd_irq_uninit\r\n&amp;quot;);
//	
//	nrfx_gpiote_in_event_disable(ADA2200_SYNCO_PIN);
//	nrfx_gpiote_in_uninit(ADA2200_SYNCO_PIN);
//}


void simple_mesurement_start(void){
	printf(&amp;quot;simple_mesurement_start\r\n&amp;quot;);

//	simple_irq_init();

	simple_adc_init();
	simple_ppi_init();
	
	simple_sampling_event_enable();
}


void simple_mesurement_stop(void){
	printf(&amp;quot;simple_mesurement_stop\r\n&amp;quot;);

	simple_sampling_event_disable();
	simple_adc_uninit();
	simple_ppi_uninit();

//	simple_irq_uninit();
}


&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Looking at the source code, is the processing of the 62.5KHz external clock pin (ADA2200_SYNCO_PIN) in the red box normal?&lt;/p&gt;
&lt;p&gt;Regardless of MCU, it should receive an external clock of 62.5KHz and PPI should perform ADC sampling on its own, but it doesn&amp;#39;t work that way.&lt;br /&gt;How do I fix my code to do that?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;SunBae Yim.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/392387?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2022 12:49:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b30da503-7a69-48a0-8885-026d2b46ef3e</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Even though you are sampling this at 62.5kHz, you should not need to execute an MCU interrupt at this interval. Much of the point of having PPI and EasyDMA is to offload the MCU for the real-time requirements, and instead the MCU only need to actively handle &amp;quot;lump&amp;quot; of data, not on a byte level, but on an array of data. So my suggestion here is that you change&amp;nbsp;SIM_SAMPLES_IN_BUFFER from 1 to 10. Then the MCU will be interrupted every 6.25kHz to process 10samples, instead of 1 sample every 62.5kHz.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/392222?ContentTypeID=1</link><pubDate>Mon, 24 Oct 2022 15:39:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:affc42f5-810f-4425-82bc-42ed7bdfde58</guid><dc:creator>ParanBada</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I implemented SAADC on a custom board using a BSP only example without using SoftDevice and BLE.&lt;br /&gt;Chipset: nRF52840CIAA&lt;/p&gt;
&lt;p&gt;This product uses an external ADA2200 (Lock-In-Amp) to generate a 62.5KHz clock (Logic Channel 7).&lt;br /&gt;This clock is input to the nRF52840 as an interrupt (Logic Channel 5).&lt;br /&gt;This interrupt does SAADC sampling through ppi (Logic Channel 3).&lt;img style="max-height:177px;max-width:691px;" alt=" " height="177" src="https://devzone.nordicsemi.com/resized-image/__size/1382x354/__key/communityserver-discussions-components-files/4/adc_5F00_drop.png" width="691" /&gt;&lt;/p&gt;
&lt;p&gt;According to the nRF52840 datasheet, the maximum sampling rate is 200KHz.&lt;br /&gt;I&amp;#39;m trying to do ADC sampling synchronized to a 62.5KHz clock. (Channel 7)&lt;br /&gt;However, as shown in the figure, 19 clocks per 100 INTs were dropped (Channel 5)&lt;br /&gt;But even worse, ADC Sampling only got 19 (Channel 3)&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:178px;max-width:695px;" alt=" " height="178" src="https://devzone.nordicsemi.com/resized-image/__size/1390x356/__key/communityserver-discussions-components-files/4/adc_5F00_drop2.png" width="695" /&gt;&lt;/p&gt;
&lt;p&gt;This is a very serious problem. The most important function of my product is to perform ADC sampling in synchronization with the 62.5KHz clock.&lt;br /&gt;However, there are too many DROPs as shown in the picture below.&lt;/p&gt;
&lt;p&gt;Looking at the second picture,&lt;br /&gt;When ADC sampling is acquired, the next interrupt is dropped. 19 interrupts dropped, 19 ADC samplings acquired.&lt;/p&gt;
&lt;p&gt;The interval time of 62.5KHz is 16uSec. ADC sampling takes more than 16uSec.&lt;/p&gt;
&lt;p&gt;I have to solve this.&lt;/p&gt;
&lt;p&gt;I share the source code I made.&amp;nbsp;&lt;a title="SAADC Sampling at 62.5 KHz" href="https://drive.google.com/file/d/1tBp8IeFoq03mxUm5P3QUvkJj_13QjYGn/view?usp=sharing"&gt;https://drive.google.com/file/d/1tBp8IeFoq03mxUm5P3QUvkJj_13QjYGn/view?usp=sharing&lt;/a&gt;&lt;br /&gt;Please check this source code. How can I solve this problem?&lt;br /&gt;And are there no mistakes in my source code? SAADC, PPI, INT.&lt;/p&gt;
&lt;p&gt;Please help and thank you.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;SunBae Yim.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/391481?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 14:52:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a8c1bd4-bd50-4b30-ac08-e3437bfa2356</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;What you are asking about here I believe is explained in the SAADC chapter:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html#concept_continuous"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html#concept_continuous&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;There is a calculation showing fSAMPLE &amp;lt; (1/(fACQ + tCONB)), best case (&amp;lt;10kohm source) &amp;lt; (1/(3us + 2us)) &amp;lt; 200kHz.&lt;/p&gt;
&lt;p&gt;Note that in your case you are sampling two channel at 62.5Hz, which in this case translate to 125kHz since there is only one ADC that sample 2 channels. So if you connect a TIMER with a timeout of (1/125kHz=) 8us, then every other analog input is sampled at 62.5kHz (with an offset of 8us).&lt;/p&gt;
&lt;p&gt;So yes, this can work, not though that sampling for 1 seconds will require 2byte * 2samples * 62.5k = 250kByte, so you need to offload this to some external memory in between here.&lt;/p&gt;
&lt;p&gt;There should be ppi examples in the SDK.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/391160?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 10:44:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82b5d670-a092-43f2-8c27-07cf14e70d70</guid><dc:creator>ParanBada</dc:creator><description>&lt;p&gt;This product must be sampled for about 5 seconds with Two ADCs (set to Diffrencial) in synchronization with an external 62.5KHz clock. The sampling period is only about 5 seconds. Instead, the sampling rate is 62.5KHz, which is very fast and the most important part.&lt;/p&gt;
&lt;p&gt;The measured data is collected in RAM, and when the measurement is finished, it is transmitted sequentially through BLE or UART.&lt;/p&gt;
&lt;p&gt;62.5KHz ADC Sampling and BLE transmission do not occur at the same time.&lt;br /&gt;This means that only the ADC should operate at 62.5KHz for about 5 seconds.&lt;/p&gt;
&lt;p&gt;Is 62.5KHz sampling possible if I use the PPI?&lt;br /&gt;Any examples to reference?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/391137?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 09:25:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b9942e2-ce86-45cf-89c9-71f86fc2fff6</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The other threads were long, I did not read all no. But I get the impression that the same discussion was performed two years ago and there have been no fundemental changes to hardware or software that will make this possible today. I can also see in the other thread that you want to measure 2 analog inputs, ref: &amp;quot;&lt;span&gt;This technology receives 62.5kHz through the interrupt pin (P.7), and needs to sample 2 ADC channels in synchronization with this interrupt clock.&lt;/span&gt;&amp;quot; This is the double of my throughput calculations.&lt;/p&gt;
&lt;p&gt;You may consider using the nRF5340 instead, then you can do all the ADC sampling on the application core and the network core will do the BLE link. However the BLE will be the same, so I don&amp;#39;t see how you are able to transfer the amount of data you want here. Have you done any calculations on the throughput you need on the link?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/391102?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 07:51:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0845d7a4-0571-41cb-b3f1-333440a71791</guid><dc:creator>ParanBada</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I asked 2 questions 2 years ago. The open question link is here.&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/support/250254"&gt;https://devzone.nordicsemi.com/support/250254&lt;/a&gt;&lt;br /&gt;And the private question is at the following link. Can I see this link here?&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/61750/what-is-the-saadc-maximum-sampling-rate-for-nrf52810"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/61750/what-is-the-saadc-maximum-sampling-rate-for-nrf52810&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/391097?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 07:44:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01e41ce1-7694-468c-9ae5-900341f4ddb1</guid><dc:creator>ParanBada</dc:creator><description>&lt;p&gt;The place I inquired about two years ago was private question.&lt;br /&gt;Can I post a private question link here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.</title><link>https://devzone.nordicsemi.com/thread/391092?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 07:34:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f12abe2-10f8-426f-975e-a268a9aa17bf</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Maybe you can share a link to the case you had two years ago so I can see what was done at the time?&lt;/p&gt;
&lt;p&gt;Looking at the saadc chapter in the datasheet:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In specific Figure 4:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/ip/saadc/doc/image/saadc.svg"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/ip/saadc/doc/image/saadc.svg&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It looks like this should be possible for instance by a gpiote event-&amp;gt;ppi-&amp;gt;sample task, then once the buffer is full you get an END event which you can handle in the SAADC interrupt.&amp;nbsp;Then you don&amp;#39;t need to handle the data at 65kHz (~15us), but for instance every 1.5ms (assuming a 100byte buffer, likely you need to double buffer, so one buffer can fill up while you are handling the other). Also I expect you need to have a ppi between END event and START task, so the next buffer is used automatically when the END event occur.&lt;/p&gt;
&lt;p&gt;I expect the main problem here will be the throughput the BLE link&amp;nbsp;must handle, e.g. if you assume every sample here is 10bit, and you are able to shift 3 10-bit samples into a 32bit word. Then you need a steady throughput of roughly 700kbps, and you can&amp;#39;t expect to get this high throughput steadily over time, and I assume you are also interested in relative low latency here (e.g. of sub &amp;lt;100ms).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So I expect the problem here is not that the hardware can&amp;#39;t handle the data throughput, the main limitiation will be the BLE link throughput.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>