2024-07-17 11:10 PM - edited 2024-07-17 11:12 PM
Hi,
I am new to STM32 MCUs and working on a small project at the moment. I following the reference manual but facing an issue that as soon as I enable ADC in CR, the MCU stops responding. I have attached the following code if someone could guide on what is wrong or missed in it.
Further, HSI has been used for clocking the MCU.
Appreciated!
// Enable Clock to GPIOA
RCC->AHBENR |= GPIOA_EN;
// PA5 as analog input
GPIOA->MODER |= (1U<<10);
GPIOA->MODER |= (1U<<11);
// Enable Clock to ADC
RCC->APB2ENR |= ADC_EN;
/* HSI14 RC Oscillator Enable Procedure */
//RCC->CR2 |= RCC_CR2_HSI14ON;
ADC1->CFGR2 |= (1U<<30);
ADC1->CFGR2 &= ~(1U<<31);
/*
while ((RCC->CR2 & RCC_CR2_HSI14RDY) ==0)
{
}
*/
/* ADC Enable Procedure */
if ((ADC1->ISR & ADC_ISR_ADRDY) != 0)
{
ADC1->ISR |= ADC_ISR_ADRDY;
}
ADC1->CR |= ADC_CR_ADEN; // STM Halts after this
while ((ADC1->ISR & ADC_ISR_ADRDY) ==0) {}
Solved! Go to Solution.
2024-07-18 12:04 AM
2024-07-18 12:04 AM
Ok, I found that there is an issue with my VDDA.
Thanks