Hi Team,
We have some application for using the oversampling code but we are facing some issue in that, we try to use the oversampling example to ours code but its calling the call back function
after the 20 triggers for these is we find in the this code.
1. is it required this much trigger ?
2. how to do for first or second trigger ?
3. this oversampling can we need more trigger to callback function ?
configuration we set this same.
#ifndef SAADC_CONFIG_OVERSAMPLE
#define SAADC_CONFIG_OVERSAMPLE 2
#endif
#ifndef SAADC_CONFIG_RESOLUTION
#define SAADC_CONFIG_RESOLUTION 3
#endif
i set the oversampling as 4x and resolution 14 bit in sdk_config file.
and also set
.acq_time = NRF_SAADC_ACQTIME_40US,
acquisition time i set to 40us.
below i mentioned enter example code.
#define SAMPLES_IN_BUFFER 5
static nrf_saadc_value_t m_buffer_pool[2][SAMPLES_IN_BUFFER];
static int temp_rotor;
static int count = 0;
int event_flag = false;
void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
printf("call trigger\n");
if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
{
int avg_sample = 0;
int i;
ret_code_t err_code;
event_flag = true;
err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAMPLES_IN_BUFFER);
APP_ERROR_CHECK(err_code);
printf("count: %d\n", count);
printf("adc-value %d\r\n", p_event->data.done.p_buffer[0]);
count++;
}
}
void saadc_init(void)
{
ret_code_t err_code;
nrf_saadc_channel_config_t channel_config =
NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN7);
err_code = nrf_drv_saadc_init(NULL, saadc_callback);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_saadc_channel_init(0, &channel_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);
}
void saadc_sampling_trigger(void)
{
printf("sample trigger call\n");
ret_code_t err_code;
event_flag = false;
//Event handler is called immediately after conversion is finished.
err_code = nrf_drv_saadc_sample(); // Check error
APP_ERROR_CHECK(err_code);
}
int main(void)
{
printf("SAADC Started...\r\n");
saadc_init();
while (true)
{
saadc_sampling_trigger();
nrf_delay_ms(1000); //waiting a second
}
}
Please find the below printed value.
We need to use the oversampling method
please let you know as soon as possible.
thanks and regards
sanjay