I am using SAADC and PPI to sample 2 channels data with oversample,when I set timer tick 5ms,the sample rate is 200hz and the system works well,now I want to improve the sample rete,So I change the timer tick to 2ms,the sample rate is 500hz.but I tested that the SAADC output data rate is up to 250hz, the timers frequency is 16M.
void ECG8233_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_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG; // timer_cfg.frequency = timer_cfg.bit_width =NRF_TIMER_BIT_WIDTH_32; err_code = nrf_drv_timer_init(&m_hardware_timer, &timer_cfg, timer_handler);//m_hardware_timer即TIMER1 APP_ERROR_CHECK(err_code); uint32_t ticks = nrf_drv_timer_ms_to_ticks(&m_hardware_timer, 2); nrf_drv_timer_extended_compare(&m_hardware_timer, NRF_TIMER_CC_CHANNEL0, ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false); nrf_drv_timer_enable(&m_hardware_timer); uint32_t timer_compare_event_addr = nrf_drv_timer_compare_event_address_get(&m_hardware_timer, NRF_TIMER_CC_CHANNEL0); uint32_t saadc_sample_task_addr = nrf_drv_saadc_sample_task_get(); 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, timer_compare_event_addr, saadc_sample_task_addr); APP_ERROR_CHECK(err_code); }
can anyone help me to solve this problem ,is there any configuration wrong?