This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Writing in SD card at fixed time-intervals by reading from ADC

Hi,

I have successfully sampled my signal using SAADC example at a sampling frequency of 10 Hz. I am using a flag in the saadc_callback() function which I read from the main() function and accordingly instruct to write the sampled data in the SD card one by one. The problem is that since I am using certain delays in the main() function for my application, the data written in the SD card is not at fixed intervals i.e. the data is missing and doesn't correspond to sampling frequency of the ADC which is obvious due to the use of delays. Is there a way of sampling and writing to SD card in parallel such as using 2 timers (one for ADC and one for SD card) ? Or any other low power method? Please provide any links to the documentation of related concepts. Thanks!

  • Hi, Have you considered using EasyDMA and PPI channels? It is possible to configure a timer to trigger SAADC sampling at accurate intervals and then have the SAADC store the sample in memory without using the CPU. This means that the timer and SAADC can do their thing in the background and your application can process the collected data whenever it has time. In more advanced cases it should also be possible to make the timer trigger SAADC sampling, and then have the SAADC trigger SPI transfers when the sampling is done. However, I'm not that familiar with SD cards, but I imaging that you might have to format the data, and maybe send some commands before being able to store the data on the card, so it might be difficult to do everything in the autonomously.

Related