Skip to content

Commit f7d081c

Browse files
authored
Merge pull request #52 from arduino-libraries/adc_dbm_fix
ADC driver fixes.
2 parents c795fbd + 434fd37 commit f7d081c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/AdvancedADC.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ int AdvancedADC::begin(uint32_t resolution, uint32_t sample_rate, size_t n_sampl
208208
}
209209

210210
// Re/enable DMA double buffer mode.
211+
HAL_NVIC_DisableIRQ(descr->dma_irqn);
211212
hal_dma_enable_dbm(&descr->dma, descr->dmabuf[0]->data(), descr->dmabuf[1]->data());
213+
HAL_NVIC_EnableIRQ(descr->dma_irqn);
212214

213215
// Init, config and start the ADC timer.
214216
hal_tim_config(&descr->tim, sample_rate);
@@ -236,8 +238,8 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *adc) {
236238
// NOTE: CT bit is inverted, to get the DMA buffer that's Not currently in use.
237239
size_t ct = ! hal_dma_get_ct(&descr->dma);
238240

239-
// Timestamp the buffer. TODO: Should move to timer IRQ.
240-
descr->dmabuf[ct]->timestamp(HAL_GetTick());
241+
// Timestamp the buffer.
242+
descr->dmabuf[ct]->timestamp(us_ticker_read());
241243

242244
if (descr->pool->writable()) {
243245
// Make sure any cached data is discarded.

src/HALConfig.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int hal_dma_config(DMA_HandleTypeDef *dma, IRQn_Type irqn, uint32_t direction) {
9191
}
9292

9393
// NVIC configuration for DMA Input data interrupt.
94-
HAL_NVIC_SetPriority(irqn, 1, 0);
94+
HAL_NVIC_SetPriority(irqn, 0, 0);
9595
HAL_NVIC_EnableIRQ(irqn);
9696

9797
return 0;

0 commit comments

Comments
 (0)