This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

A plurality of A / D conversion processing

How can I perform multiple A / D conversion?
I created a program with reference to the method of the old version of A / D conversion, but the function name and argument used are different and it does not work.
Please tell me how to do with "nRF5_SDK_15.0.0_a53641a" version.
Thanking you in advance.
Parents
  • Hey Yokokawa-san,

    You need to use the SAADC driver API documentation. I also suggest that you compare the SAADC example of SDK15 with your old implementation. 

    The programming flow when using multiple ADC channels is as follows: 

    1. Initialize the SAADC driver with a call to nrfx_saadc_init.
    2. Calibrate the offset with a call to nrfx_saadc_calibrate_offset. You need to wait for the SAADCs DONE event before you can proceed.
    3. Initialize the SAADC channels you want to use with calls to nrfx_saadc_channel_init.
    4. The SAADC will now sample all enabled channels sequentially when a SAMPLE task is triggered. 

    Cheers,

    Håkon.

  • I created the following program, but when I execute "nrfx_saadc_calibrate_offset ()", 
    I get an error with "nrf_drv_saadc_channel_init ()". Please tell me what processing is missing.
    ---------------------------------------------

    void saadc_init(void)
    {
        ret_code_t err_code;

    /*-< SAADC Register initial parameter >-*/
        nrf_drv_saadc_config_t saadc_config = NRF_DRV_SAADC_DEFAULT_CONFIG; 

    /*-< SAADC Channel Setting parameter >-*/
        nrf_saadc_channel_config_t channel0_config =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);    /* Channel 0 data */
        nrf_saadc_channel_config_t channel1_config =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN1);    /* Channel 1 data */

    /*-< SAADC initial >-*/
        err_code = nrf_drv_saadc_init(&saadc_config, saadc_callback);
        APP_ERROR_CHECK(err_code);

    /*-<ADC offset calibration >-*/
        err_code = nrfx_saadc_calibrate_offset();
        APP_ERROR_CHECK(err_code);

    /*-< SAADC Channel Setting >-*/
        err_code = nrf_drv_saadc_channel_init(0, &channel0_config);    /* Channel 0 */
        APP_ERROR_CHECK(err_code);
        err_code = nrf_drv_saadc_channel_init(1, &channel1_config);    /* Channel 1 */
        APP_ERROR_CHECK(err_code);

    /*-<SAADC double baffer Setting >-*/
        err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAADC_SAMPLES_IN_BUFFER);    /* 1st buffer  */
        APP_ERROR_CHECK(err_code);
        err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAADC_SAMPLES_IN_BUFFER);    /* 2nd buffer */
        APP_ERROR_CHECK(err_code);

    }

    ---------------------------------------------
    Thanking you in advance.
     
  • /*-<ADC offset calibration >-*/
        err_code = nrfx_saadc_calibrate_offset();
        APP_ERROR_CHECK(err_code);
        
        while(nrfx_saadc_is_busy()) // Wait for calibration to complete
        {
            __WFE();    //
            __SEV();    //
            __WFE();    // This sequence puts the system to sleep (SystemON) while waiting
        }
    
    /*-< SAADC Channel Setting >-*/ 
        err_code = nrf_drv_saadc_channel_init(0, &channel0_config);    /* Channel 0 */
        APP_ERROR_CHECK(err_code);

Reply Children
No Data
Related