diff --git a/src/AdvancedADC.cpp b/src/AdvancedADC.cpp index ee4ae1f..49f7e23 100644 --- a/src/AdvancedADC.cpp +++ b/src/AdvancedADC.cpp @@ -208,7 +208,9 @@ int AdvancedADC::begin(uint32_t resolution, uint32_t sample_rate, size_t n_sampl } // Re/enable DMA double buffer mode. + HAL_NVIC_DisableIRQ(descr->dma_irqn); hal_dma_enable_dbm(&descr->dma, descr->dmabuf[0]->data(), descr->dmabuf[1]->data()); + HAL_NVIC_EnableIRQ(descr->dma_irqn); // Init, config and start the ADC timer. hal_tim_config(&descr->tim, sample_rate); @@ -236,8 +238,8 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *adc) { // NOTE: CT bit is inverted, to get the DMA buffer that's Not currently in use. size_t ct = ! hal_dma_get_ct(&descr->dma); - // Timestamp the buffer. TODO: Should move to timer IRQ. - descr->dmabuf[ct]->timestamp(HAL_GetTick()); + // Timestamp the buffer. + descr->dmabuf[ct]->timestamp(us_ticker_read()); if (descr->pool->writable()) { // Make sure any cached data is discarded. diff --git a/src/HALConfig.cpp b/src/HALConfig.cpp index f6a7103..493f3f9 100644 --- a/src/HALConfig.cpp +++ b/src/HALConfig.cpp @@ -91,7 +91,7 @@ int hal_dma_config(DMA_HandleTypeDef *dma, IRQn_Type irqn, uint32_t direction) { } // NVIC configuration for DMA Input data interrupt. - HAL_NVIC_SetPriority(irqn, 1, 0); + HAL_NVIC_SetPriority(irqn, 0, 0); HAL_NVIC_EnableIRQ(irqn); return 0;