2019-06-05 07:05 AM
Hi,
I got a problem with STM32G070RBTx ADC configuration. I configured ADC in interrupt mode. After each conversion I change channel to measure different pin.
I got 9 pins to measure(PA0 - PA7 and PB12). With PINS on PORTA I got no problem but PB12 is problematic. According to datasheet it is connected to ADC1_IN16, but configuring Channel as ADC_CHANNEL_16 measure PA0 instead of PB12.
Here is the function to change channels in adc:
void config_ext_channel_ADC(uint32_t channel)
{
ADC_ChannelConfTypeDef sConfig = {0};
switch(channel)
{
case 0:
sConfig.Channel = ADC_CHANNEL_0;
break;
case 1:
sConfig.Channel = ADC_CHANNEL_1;
break;
case 2:
sConfig.Channel = ADC_CHANNEL_2;
break;
case 3:
sConfig.Channel = ADC_CHANNEL_3;
break;
case 4:
sConfig.Channel = ADC_CHANNEL_4;
break;
case 5:
sConfig.Channel = ADC_CHANNEL_5;
break;
case 6:
sConfig.Channel = ADC_CHANNEL_6;
break;
case 7:
sConfig.Channel = ADC_CHANNEL_7;
break;
case 8:
sConfig.Channel = ADC_CHANNEL_16;
break;
case 9:
sConfig.Channel = ADC_CHANNEL_TEMPSENSOR;
break;
case 10:
sConfig.Channel = ADC_CHANNEL_VBAT;
break;
case 11:
sConfig.Channel = ADC_CHANNEL_VREFINT;
break;
}
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLINGTIME_COMMON_1;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
}
What am I doing wrong?
Thanks in advance
2019-10-08 03:30 AM
I have the same issue in STM32G031K8.
It seems to be hardware related bug beacuse register values in HAL looks ok.
2019-11-11 04:23 AM
Hello Olek,
May I ask you to share as well the mode selection of the ADC?
In ADC_CFGR1 register: Bit 21 CHSELRMOD: Mode selection of the ADC_CHSELR register
If set to '1', you use then the sequencer which can only manipulate Ch0 to CH14, selection is made on 4 bits, and an overflow of the bitfield would explain what you observe.
I am surprised that software would not spot this however.
Regards,
Antoine
2020-07-21 09:21 AM
I am running into the same issue with the inability to read ADC1_IN16. I see in the RM0454 Reference Manual it states "Only channel 0 to channel 14 can be selected in this sequence". So is there no way to select ADC1_IN16 and read its input level?