I'm upgrading my code to SDK 15.2. I use TIMER1 and PPI to trigger SAADC sampling. The same to what I was doing on SDK 12.3. I was doing 100Hz sampling, but was hoping to increase this to 225Hz. I migrated my code, with the new nrfx_timer module as follows:
nrfx_timer_config_t timer_cfg = NRFX_TIMER_DEFAULT_CONFIG;
timer_cfg.mode = NRF_TIMER_MODE_TIMER;
timer_cfg.bit_width = NRF_TIMER_BIT_WIDTH_16;
timer_cfg.frequency = (nrf_timer_frequency_t)NRF_TIMER_FREQ_1mMHz;
err_code = nrfx_timer_init(&my_saadc_timer, &timer_cfg, timer_handler);
APP_ERROR_CHECK(err_code);
/* setup m_timer for compare event every interval */
uint32_t ticks = nrfx_timer_ms_to_ticks(&my_saadc_timer, 4); // 4msec
nrfx_timer_extended_compare(&my_saadc_timer,
NRF_TIMER_CC_CHANNEL1,
ticks,
NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK,
false);
nrfx_timer_enable(&my_saadc_timer);
/* setup ppi channel so that timer compare event is triggering sample task in SAADC */
err_code = nrfx_ppi_channel_alloc(&m_ppi_channel);
APP_ERROR_CHECK(err_code);
uint32_t timer_compare_event_addr = nrfx_timer_compare_event_address_get(&my_saadc_timer, NRF_TIMER_CC_CHANNEL1);
uint32_t saadc_sample_task_addr = nrfx_saadc_sample_task_get();
err_code = nrfx_ppi_channel_assign( m_ppi_channel,
timer_compare_event_addr,
saadc_sample_task_addr);
APP_ERROR_CHECK(err_code);
err_code = nrfx_ppi_channel_enable(m_ppi_channel);
APP_ERROR_CHECK(err_code);
This code is a pretty straight forward migration of the API to nrfx. However for some reason instead of 4msec sample intervals, I'm seeing 16msec sample intervals. Essentially 4x.
This seems to be an issue unless I select the 16Hz frequency. Curious if this is a bug in the driver or I've implemented something wrong here?
Thanks guys,