Why is my ADC reading zero for values?
My objective is to utilize ADC peripheral for reading analog signals and converting them to digital. I am using the polling method for reading ADC values. When setting up the chip configuration, I am currently using the Nucleo-H743ZI with default settings. After enabling ADC1, I enable continuous conversion mode, end of conversion mode to end of sequence selection and lastly, enable regular conversions. I would also like to send that data to a serial monitor to log data, therefore I will be using USART3. USART3 was already initialized by default settings and I'll be using default settings. Save and generate code.




The polling method requires 3-4 steps:
(+++) Activate the ADC peripheral and start conversions using function HAL_ADC_Start()
(+++) Wait for ADC conversion completion using function HAL_ADC_PollForConversion()
(+++) Retrieve conversion results using function HAL_ADC_GetValue()
(+++) Stop conversion and disable the ADC peripheral using function HAL_ADC_Stop()
After opening main.c , I create a few variables and lines of code.
int main(void)
{
/* USER CODE BEGIN 1 */
uint8_t MSG[35] = {'\0'};
uint32_t X = 0;
uint16_t adc_value = 0;
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_ETH_Init();
MX_USART3_UART_Init();
MX_USB_OTG_FS_PCD_Init();
MX_ADC1_Init();
MX_ADC2_Init();
MX_TIM2_Init();
while (1)
{
// Start ADC Conversion
HAL_ADC_Start(&hadc1);
// Poll ADC1 Perihperal & TimeOut = 1mSec
HAL_ADC_PollForConversion(&hadc1, 1);
// Read The ADC Conversion Result
adc_value = (uint8_t)HAL_ADC_GetValue(&hadc1);
sprintf((char*)MSG, "Digital Value = %lu \r\n", adc_value);
HAL_UART_Transmit(&huart3, (uint8_t*)MSG, sizeof(MSG), 100);
HAL_Delay(500);
My question is why am I reading zero? I have this circuit set up, only difference is instead of A0 I have to locate PA0 (ADC1) which can be easily found. So why is this happening?
