/** * @brief Starts an ADC conversion. * * @param[in] adcp pointer to the @p ADCDriver object * * @notapi */ void adc_lld_start_conversion(ADCDriver *adcp) { uint32_t mode, n, cr2; const ADCConversionGroup *grpp = adcp->grpp;
/* DMA setup.*/ mode = adcp->dmamode; if (grpp->circular) mode |= STM32_DMA_CR_CIRC; if (adcp->depth > 1) { /* If the buffer depth is greater than one then the half transfer interrupt interrupt is enabled in order to allows streaming processing.*/ mode |= STM32_DMA_CR_HTIE; n = (uint32_t)grpp->num_channels * (uint32_t)adcp->depth; } else n = (uint32_t)grpp->num_channels; dmaStreamSetMemory0(adcp->dmastp, adcp->samples); dmaStreamSetTransactionSize(adcp->dmastp, n); dmaStreamSetMode(adcp->dmastp, mode); dmaStreamEnable(adcp->dmastp);
Giovanni wrote:If you need to make conversions at intervals you don't even need to touch a timer, there are several other ways: 1) A periodic thread. 2) A virtual timer callback. 3) A GPT driver callback.
Giovanni,
How much jitter is there in using a GPT callback? I'm using that method right now to drive periodic ADC samples. One of the requirements (unimplemented for now) is that the code calculate the frequency of the analog signal. My assumption has been that ultimately, I'd have to use a hardware timer to get enough precision. My sampling frequency isn't that high--maybe 10kHz.
The Jitter depends mainly on the priority you assign to that GPT, potentially it can be very low if you don't have ISRs at higher priority (there is no intrinsic jitter in the callback), the kernel doesn't affect this much, the kernel contribution to the jitter increases linearly with the number of threads but it very low anyway.