Solved
ADC: Cannot change channel.
Board: STM32WB55-NUCLEO Pack
I am unable to change the channel being read by the ADC using the included code.
I have set the number of conversion to 3 in the ADC configurations. I am not using the DMA but am polling.
uint32_t get_battery_voltage(){
sConfig.Channel = ADC_CHANNEL_3 ;
sConfig.Rank = 1;
if (HAL_ADC_ConfigChannel(&hadc1,&sConfig) != HAL_OK)
{
Error_Handler();
}
HAL_ADC_Start(&hadc1);
if(HAL_ADC_PollForConversion(&hadc1,5)==HAL_OK){
state.battery_voltage = (double)(HAL_ADC_GetValue(&hadc1));
state.battery_voltage = (state.battery_voltage/4095)*3.3;
}
HAL_Delay(50);
HAL_ADC_Stop(&hadc1);
return state.battery_voltage;
}