Hello Guys, I am try to get the STM32F446RE to read analog signals from a potentiometer and I just cant seem to get it right please help me out, can I please get an example code that works cause even uploading the code I have written just isn't working right now.
An idea is to compare your application with example projects offered by the Pack Installer of Keil MDK:
Hello sing did you find the solution because i am also stuck at the same point. Tried so many methods but not found the right solution, i am using the ABOV Microcontroller where as you used stm one. So please let me know if you found the solution for this waiting
Waiting for your reply!!!
Hello, I have moved your question to the Keil forum, however you are more likely to get a response from a device specific query like this from the STM32 specific forum below (ST website):
https://community.st.com/s/topic/0TO0X000000BSqSWAW/stm32-mcus
Here is my attempt to initialize it
//set clock to 14MHz prscaler ADC->CCR |= ADC_CCR_ADCPRE_0; ADC->CCR |= ADC_CCR_ADCPRE_1; ADC->CCR |= ADC_CCR_TSVREFE; //RCC clock for ADC and for alternate function RCC->APB2ENR |= RCC_APB2ENR_ADC1EN; //Enable GPIO port CLOCK_INIT_PORTA();
//configure input push pull //setting up the input //setting up the mode GPIOA->MODER |= (GPIO_MODER_MODE2_1); GPIOA->MODER |= (GPIO_MODER_MODE2_0);//11 input output //setting up the PUPDR //since we have pulled down push pull alternate function GPIOA->PUPDR &=~(GPIO_PUPDR_PUPD2_0); GPIOA->PUPDR &=~(GPIO_PUPDR_PUPD2_1);//analog value //Enable end of conversion interrupt ADC1->CR1 |= ADC_CR1_EOCIE; //ADC Resolution 8 bit ADC1->CR1 &=~ ADC_CR1_RES_0; ADC1->CR1 |= ADC_CR1_RES_1; //Set sampling rate choose maximum for the highst precision ADC1->SMPR2 |= ADC_SMPR2_SMP2_0; ADC1->SMPR2 |= ADC_SMPR2_SMP2_1; ADC1->SMPR2 |= ADC_SMPR2_SMP2_2; //set channels in sequence reg ADC1->SQR3 |= ADC_SQR3_SQ1_1; //Enable ADC that is ADON //Enable continuous mode ADC1->CR2 |= (ADC_CR2_ADON)|(ADC_CR2_CONT); //delai for 2ms wait_For_t(20); //turn on ADC adon for the second time //delay 2 ms ADC1->CR2 |= ADC_CR2_ADON; wait_For_t(20); //Run clibration //delay to allow the finish wait_For_t(2);
I am using Kiel IDE