AnsweredAssumed Answered

What is the minimum clock speed if I use ADC with DMA?

Question asked by Nazim Nuriev on Mar 3, 2017
Latest reply on Mar 4, 2017 by waclawek.jan

I use STM32L151 for digitizing 3 values: Vrefint, Temp.sensor and 1 external source. Program uses sleep mode.

I get garbage after switching CPU freq from 250 kHz to 4 mHz and correct values when switching from 500 kHz to 4 mHz. Both freq's based on HSI source. ADC RESOLUTION - 12 bit

 

(DMA init omitted)

ADC init code...

ADC->CCR = ADC_CCR_TSVREFE;

ADC1->CR1 = ADC_CR1_PDI | ADC_CR1_SCAN;

ADC1->CR2 = ADC_CR2_DDS;

// Enable DMA mode
ADC1->CR2 |= ADC_CR2_DMA;

ADC1->SQR1 = ((3 - 1) << 20);

ADC1->SQR5 = (6 << 0) | (17 << 5) | (16 << 10);

// vtest 192 cycles
ADC1->SMPR3 = (6 << 0);

//                         Vrefint 192 cycles         Temp sensor 384 cycles
//                         chan 17                        chan 16
ADC1->SMPR2 = (6 << ((17 - 10) * 3)) | (7 << ((16 - 10) * 3));

 

// DMA1_Channel1_IRQn interrupt configuration
DMA1_Channel1->CCR |= DMA_CCR_EN;

ADC1->CR2 |= ADC_CR2_ADON;

// Enable DMA transfer complete
DMA1_Channel1->CCR |= DMA_CCR_TCIE;
NVIC_EnableIRQ(DMA1_Channel1_IRQn);

 

Every 250 ms I read previous ADC values from dedicated memory and then ADC starts with:

   ADC1->SR &= ~(ADC_SR_EOC | ADC_SR_OVR);

   // ADC1 regular conversion start
   ADC1->CR2 |= ADC_CR2_SWSTART;

Outcomes