This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32f407VG ADC

Hi, I am new to this community and this is my first question. My project is to read the Voltage from potentiometer which is connected to the PA0 (ADC channel 0). So, I want to practice ADC in STM32f4xx. I inserted my code here. I can read analog values, bu the problem that they are very inconsistent, namely they are not constant and differ from each other significantly. I searched datasheet and user manual, but I couldn't solve the problem. Please can you inform me what is my problem here? Thank you very much.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "stm32f4xx.h"
#include "LCDFunctions.h"
int main(void)
{
LCDInitializePorts();
LCDClearDisplay();
GPIOA->MODER |= GPIO_MODER_MODE0_Msk;
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN;
ADC1->SQR1 = 0x00000000;
ADC1->SQR2 = 0x00000000;
ADC1->SQR3 = 0x00000000;
ADC1->SMPR2 = 0x00000005;
ADC1->CR2 |= ADC_CR2_CONT_Msk;
ADC1->CR1 &= ~(ADC_CR1_SCAN_Msk);
ADC1->CR2 |= ADC_CR2_ADON;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

0