ADC register ADRDY never sets when I enable the ADC, so it keeps waiting there to start STM32F303RBT6
Hi all,
I have this problem. I want to start the ADC of my microcontroller, and following the reference manual it says I have to wait until the ADRDY register is set by the hardware to continue and make conversions, but that register never sets. This is my code:
This function enables the DMA fot the ADC
void DMA_Init(ADC_TypeDef * adc, DMA_Channel_TypeDef * dma_ch, std::uint16_t * buffer, std::uint32_t buffer_length,std::uint8_t length){
adc->CFGR |= ADC_CFGR_CONT;
adc->CFGR |= ADC_CFGR_DMAEN | ADC_CFGR_DMACFG;
adc->SMPR1 |= (7U << 3U) | (7U << 6U); //max sampling rate
dma_ch->CPAR = (std::uint32_t)(&adc->DR);
dma_ch->CMAR = (std::uint32_t)(buffer);
dma_ch->CNDTR = buffer_length;
dma_ch->CCR |= DMA_CCR_EN;
Enable_regulator(adc);
Enable(adc);
Calib(adc);
Enable(adc);
}So these are the enable regulator and enable functions:
void Enable_regulator(ADC_TypeDef * adc){
adc->CR &= ~(ADC_CR_ADVERGEN_CLEAR);
adc->CR |= ADC_CR_ADVERGEN_ENABLE;
utils::delay::us(30);
}
void Enable(ADC_TypeDef * adc){
adc->CR |= ADC_CR_ADEN;
while(!(adc->ISR & ADC_ISR_ADRDY)){}
}The enable regulator works perfectly. But the enable function keeps waiting forever. Any help would be great.
Thanks!
