Hello,
I would like to be able to sample an analog voltage signal with a sample rate of approximately 250us (4096 samples/sec). I am using the SAADC example in nRF5 SDK v12.2.0, and the code is running fine. I am reading the ADC value using the PUTTY serial monitor, by connecting GPIO pin 2 to either GND or VCC. In the example code the following configuration is made to set up a 400ms sample rate (as I understand it):
/* setup m_timer for compare event every 400ms */
uint32_t ticks = nrf_drv_timer_ms_to_ticks(&m_timer, 1000); // us_to_ticks also exists uint32_t nrf_drv_timer_us_to_ticks
nrf_drv_timer_extended_compare(&m_timer,
NRF_TIMER_CC_CHANNEL0,
ticks,
NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK,
false);
But in the above code the sample rate can't be set lower than 1ms. I am now trying to use 'us_to_ticks' as shown below to be able to set the sample rate to 250us:
uint32_t ticks = nrf_drv_timer_us_to_ticks(&m_timer, 250);
But when I do this all I get is an 'Overflow' in the PUTTY terminal window. As soon as I change the input parameter to 1000 us it works again. As far as I can see the Timer frequency is set to 16MHz (TIMER_DEFAULT_CONFIG_FREQUENCY 0), so it should be possible to get ADC sampling faster than 1ms I assume..?
Any help is greatly appreciated. Thanks.
Cheers,
Jan