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

real-time task :: sample ADC and store at close to maximal 50khz

Hello, I've searched the forum for information regarding handling real-time tasks with the nrf51822. I've found this post -- devzone.nordicsemi.com/.../ -- which is similar to my situation.

I'm analyzing a real time process which requires me to sample analog voltages at 40khz. The logical way to go about this is to sample the ADC ( 20us conversion at 8 bit ) and save the value using DMA (direct memory access). This process can start at any time, and doesn't need to last more than 1ms, but it's absolutely critical that the real-time nature is not interrupted by anything during this time.

What are the best practices here?

If ADC and DMA is the only thing that i'm doing during this time frame do I need to be generating interrupts with an RTC to trigger or is there something simpler? Are there any benchmark implementations validating the maximum rate at which the nRF51822 can fill a buffer using the ADC?

Thanks

Parents
  • The ADC peripheral on the nrf51822 doesn't have DMA, perhaps you didn't mean that, you just meant 'write the value to RAM in code', that's what you're going to have to do either way. So you set up a timer for 40kHz using PPI to trigger the ADC to start every 25us, you either write the next value to RAM in an interrupt handler or you run in a tight loop waiting for END then waiting for the next BUSY and the next END and stop when you have all the samples you need.

    Assuming you're going to be using the softdevice at the same time then you'll need to use the timeslot API to give yourself 1ms + overhead to do this. Since you say it doesn't matter when you start that's fine for the timeslot api as it will give you 1ms+ when it has it available, you do your stuff, you won't be interrupted.

Reply
  • The ADC peripheral on the nrf51822 doesn't have DMA, perhaps you didn't mean that, you just meant 'write the value to RAM in code', that's what you're going to have to do either way. So you set up a timer for 40kHz using PPI to trigger the ADC to start every 25us, you either write the next value to RAM in an interrupt handler or you run in a tight loop waiting for END then waiting for the next BUSY and the next END and stop when you have all the samples you need.

    Assuming you're going to be using the softdevice at the same time then you'll need to use the timeslot API to give yourself 1ms + overhead to do this. Since you say it doesn't matter when you start that's fine for the timeslot api as it will give you 1ms+ when it has it available, you do your stuff, you won't be interrupted.

Children
No Data
Related