SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.

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.
However, the nRF52840 doesn't seem to be able to handle this speed.
The SAADC handler comes out too late.
I use s140_nrf52_7.2.0_softdevice.hex for soft device.

Please give me an answer on how to implement saadec two channel diffrencial type sampling at 62.5Khz rate.

Parents
  • Hello,

    You said:
    " 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,......"

    So I followed your advice and deleted the [interrupt function] as in the following code.
    By the way, simple_voltage_handler() is not called. Why?

    /*******************************************************************************
     * @file	meas_pd_voltage.c
     * @author	CandyPops Co.
     * @version	V1.0.0
     * @date	2022-09-05
     * @brief   
     ******************************************************************************/
    
    #include "sdk_common.h"
    			
    #include <stdbool.h>
    #include <stdint.h>
    #include <stdio.h>
    #include <string.h>
    #include "nrf.h"
    #include "boards.h"
    #include "app_error.h"
    #include "nrf_drv_saadc.h"
    #include "nrfx_gpiote.h"
    #include "nrf_drv_gpiote.h"
    #include "nrf_drv_ppi.h"
    #include "nrf_drv_timer.h"
    #include "nrf_delay.h"
    
    #include "meas_pd_voltage_simple.h"
    
    
    #define PD_REF_VOLTAGE_IN_MILLIVOLTS   		600.0f                                     /**< Reference voltage (in milli volts) used by ADC while doing conversion. */
    #define PD_PRE_SCALING_COMPENSATION    		6.0f                                       /**< 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                                    /**< 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("simple_ppi_init\r\n");
    
        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(&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("simple_ppi_uninit\r\n");
    
        err_code = nrf_drv_ppi_uninit();
        APP_ERROR_CHECK(err_code);
    }
    
    
    void simple_sampling_event_enable(void)
    {
    	printf("simple_sampling_event_enable\r\n");
    
        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("simple_sampling_event_disable\r\n");
    
    	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("p\r\n");
    
        if (p_event->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->data.done.p_buffer, SIM_SAMPLES_IN_BUFFER);
    
    		pd_voltage_in_milli_volts = PD_VOUT_IN_MILLI_VOLTS(p_event->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("iDx = %d \r\n", pd_voltage_buff_idx);
    			printf("sim_call_cnt=%d, sim_ans_cnt=%d\r\n", sim_call_cnt, sim_ans_cnt);
    			
    			for(uint8_t i = 0; i < 110; i++) {
    				printf(" %f ", pd_voltage_buff[i]);
    			}
    			printf("\r\n === TEST END === \r\n\r\n");
    
    			
    
    			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("simple_adc_init\r\n");
    
    
    	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(&default_config, simple_voltage_handler);
    	APP_ERROR_CHECK(err_code);
    
    	err_code = nrf_drv_saadc_channel_init(0, &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("simple_adc_uninit\r\n");
    
    	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("iDx = %d \r\n", pd_voltage_buff_idx);
    ////			printf("sim_call_cnt=%d, sim_ans_cnt=%d\r\n", sim_call_cnt, sim_ans_cnt);
    ////			
    ////			for(uint8_t i = 0; i < 110; i++) {
    ////				printf(" %f ", pd_voltage_buff[i]);
    ////			}
    ////			printf("\r\n === TEST END === \r\n\r\n");
    ////
    ////			
    ////
    ////			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("simple_irq_init\r\n");
    //
    //	/* 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, &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("pd_irq_uninit\r\n");
    //	
    //	nrfx_gpiote_in_event_disable(ADA2200_SYNCO_PIN);
    //	nrfx_gpiote_in_uninit(ADA2200_SYNCO_PIN);
    //}
    
    
    void simple_mesurement_start(void){
    	printf("simple_mesurement_start\r\n");
    
    //	simple_irq_init();
    
    	simple_adc_init();
    	simple_ppi_init();
    	
    	simple_sampling_event_enable();
    }
    
    
    void simple_mesurement_stop(void){
    	printf("simple_mesurement_stop\r\n");
    
    	simple_sampling_event_disable();
    	simple_adc_uninit();
    	simple_ppi_uninit();
    
    //	simple_irq_uninit();
    }
    
    
    

    Looking at the source code, is the processing of the 62.5KHz external clock pin (ADA2200_SYNCO_PIN) in the red box normal?

    Regardless of MCU, it should receive an external clock of 62.5KHz and PPI should perform ADC sampling on its own, but it doesn't work that way.
    How do I fix my code to do that?

    Best Regards,

    SunBae Yim.

Reply
  • Hello,

    You said:
    " 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,......"

    So I followed your advice and deleted the [interrupt function] as in the following code.
    By the way, simple_voltage_handler() is not called. Why?

    /*******************************************************************************
     * @file	meas_pd_voltage.c
     * @author	CandyPops Co.
     * @version	V1.0.0
     * @date	2022-09-05
     * @brief   
     ******************************************************************************/
    
    #include "sdk_common.h"
    			
    #include <stdbool.h>
    #include <stdint.h>
    #include <stdio.h>
    #include <string.h>
    #include "nrf.h"
    #include "boards.h"
    #include "app_error.h"
    #include "nrf_drv_saadc.h"
    #include "nrfx_gpiote.h"
    #include "nrf_drv_gpiote.h"
    #include "nrf_drv_ppi.h"
    #include "nrf_drv_timer.h"
    #include "nrf_delay.h"
    
    #include "meas_pd_voltage_simple.h"
    
    
    #define PD_REF_VOLTAGE_IN_MILLIVOLTS   		600.0f                                     /**< Reference voltage (in milli volts) used by ADC while doing conversion. */
    #define PD_PRE_SCALING_COMPENSATION    		6.0f                                       /**< 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                                    /**< 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("simple_ppi_init\r\n");
    
        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(&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("simple_ppi_uninit\r\n");
    
        err_code = nrf_drv_ppi_uninit();
        APP_ERROR_CHECK(err_code);
    }
    
    
    void simple_sampling_event_enable(void)
    {
    	printf("simple_sampling_event_enable\r\n");
    
        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("simple_sampling_event_disable\r\n");
    
    	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("p\r\n");
    
        if (p_event->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->data.done.p_buffer, SIM_SAMPLES_IN_BUFFER);
    
    		pd_voltage_in_milli_volts = PD_VOUT_IN_MILLI_VOLTS(p_event->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("iDx = %d \r\n", pd_voltage_buff_idx);
    			printf("sim_call_cnt=%d, sim_ans_cnt=%d\r\n", sim_call_cnt, sim_ans_cnt);
    			
    			for(uint8_t i = 0; i < 110; i++) {
    				printf(" %f ", pd_voltage_buff[i]);
    			}
    			printf("\r\n === TEST END === \r\n\r\n");
    
    			
    
    			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("simple_adc_init\r\n");
    
    
    	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(&default_config, simple_voltage_handler);
    	APP_ERROR_CHECK(err_code);
    
    	err_code = nrf_drv_saadc_channel_init(0, &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("simple_adc_uninit\r\n");
    
    	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("iDx = %d \r\n", pd_voltage_buff_idx);
    ////			printf("sim_call_cnt=%d, sim_ans_cnt=%d\r\n", sim_call_cnt, sim_ans_cnt);
    ////			
    ////			for(uint8_t i = 0; i < 110; i++) {
    ////				printf(" %f ", pd_voltage_buff[i]);
    ////			}
    ////			printf("\r\n === TEST END === \r\n\r\n");
    ////
    ////			
    ////
    ////			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("simple_irq_init\r\n");
    //
    //	/* 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, &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("pd_irq_uninit\r\n");
    //	
    //	nrfx_gpiote_in_event_disable(ADA2200_SYNCO_PIN);
    //	nrfx_gpiote_in_uninit(ADA2200_SYNCO_PIN);
    //}
    
    
    void simple_mesurement_start(void){
    	printf("simple_mesurement_start\r\n");
    
    //	simple_irq_init();
    
    	simple_adc_init();
    	simple_ppi_init();
    	
    	simple_sampling_event_enable();
    }
    
    
    void simple_mesurement_stop(void){
    	printf("simple_mesurement_stop\r\n");
    
    	simple_sampling_event_disable();
    	simple_adc_uninit();
    	simple_ppi_uninit();
    
    //	simple_irq_uninit();
    }
    
    
    

    Looking at the source code, is the processing of the 62.5KHz external clock pin (ADA2200_SYNCO_PIN) in the red box normal?

    Regardless of MCU, it should receive an external clock of 62.5KHz and PPI should perform ADC sampling on its own, but it doesn't work that way.
    How do I fix my code to do that?

    Best Regards,

    SunBae Yim.

Children
No Data
Related