ADC and accurate timing
Posted: Tue Mar 26, 2024 11:18 pm
Hi forum.
I would like to sample within a specific window, using continuous mode and the DMA feature. I finally seems to have the ADC and DMA working correctly, but I am facing some problems...
I have an GPIO input, that should start and stop the sampling, with as big accuracy as possible.
- How do I start the sampling accurate when the timer interupt occurs? I can not call the adc_continuous_start from within the ISR, that causes an reboot. I think, that it takes too long, or is blocking - but not sure exactly why it fails. But it does.
- And I also want to stop the sampling the same way.
- And I would like to read the buffer, after I stop the sampling, but it seems like the resources are not available anymore. I get a ADC stopped error.
- And lastly, I would like to clear the buffer and ADC and start from scratch, making a new sampling. The only way I can see, is to adc_continuous_deinit everything. Is there a way just to reset the buffer?
I want to sample 4 channels for 100mS, at 10KHz making that a total of 4.000 samples. And my initial thought, was simply to make the buffer large enough, and read it, to avoid any ISR to handle sample data. I should have plenty of resources available.
But how do I make a precision timed sampling? Any ideas?
I would like to sample within a specific window, using continuous mode and the DMA feature. I finally seems to have the ADC and DMA working correctly, but I am facing some problems...
I have an GPIO input, that should start and stop the sampling, with as big accuracy as possible.
- How do I start the sampling accurate when the timer interupt occurs? I can not call the adc_continuous_start from within the ISR, that causes an reboot. I think, that it takes too long, or is blocking - but not sure exactly why it fails. But it does.
- And I also want to stop the sampling the same way.
- And I would like to read the buffer, after I stop the sampling, but it seems like the resources are not available anymore. I get a ADC stopped error.
- And lastly, I would like to clear the buffer and ADC and start from scratch, making a new sampling. The only way I can see, is to adc_continuous_deinit everything. Is there a way just to reset the buffer?
I want to sample 4 channels for 100mS, at 10KHz making that a total of 4.000 samples. And my initial thought, was simply to make the buffer large enough, and read it, to avoid any ISR to handle sample data. I should have plenty of resources available.
But how do I make a precision timed sampling? Any ideas?