We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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.
#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; while(1) { ADC1->CR2 |= ADC_CR2_SWSTART_Msk; LCDSendAnInteger((ADC1->DR), 7); notExactTimeDelay(1000000); LCDClearDisplay(); } }