This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with SAADC examples for audio sampling

I am using nRF52 pca10400 and I would sample some audio signal for short periods of time, but I found a lot of difficulties with the SAADC example from sdk 13, since if I put a value greater than 126 in SAMPLES_IN_BUFFER I get overflow.

image description

I would also increase the sampling frequency by the variable ticks, but the minimum value allowed is 1 [ms] for this variable since it is declared as uint_32. So it means I can reach a maximum sampling frequency of 1kHz (?).

image description

Can I modify in some way the function nrf_drv_timer_ms_to_ticks in order to get a higher sampling frequency?

Thank you.

  • What exactly do you mean by that you get overflow? Do the logging to UART overflow, or is there some issue with the sampling? There is also a function nrf_drv_timer_us_to_ticks, which can be used for higher sample rates. You can also set the ticks parameter manually, by calculating the desired ticks from the frequency of the timer (16 MHz by default). You can find the documentation of the TIMER peripheral here.

  • Hi, thanks for your support. I think that the overflow is from the logging to UART, and it's good to hear. I fixed the sampling frequency to 50kHz (sampling time 20us) with nrf_drv_timer_us_to_ticks and I tried to run again the example with a buffer of 64 samples, obtaining this from the terminal: The first event has correctly 64 samples but the second one has only 60 followed by overflows. How can we fix the UART overflow problem?

  • You can try to increase the UART string length NRF_LOG_BACKEND_MAX_STRING_LENGTH and buffer size if using NRF_LOG_DEFERRED, NRF_LOG_DEFERRED_BUFSIZE. You can also try with a higher baudrate for the UART communication, NRF_LOG_BACKEND_SERIAL_UART_BAUDRATE. All these parameters can be configured in sdk_config.h. You can also try using RTT as the backend for NRF_LOG, and use J-Link RTT Viewer to view the samples.

  • Thank You Jørgen, your information were very useful.

Related