2022-07-21 05:10 AM
I have trouble reading from 17th channel of STM32G0B1 MCU, which is PC4 pin.
I have to read from channel 0 and 17. If I configure ADC for single channel it reads fine from Ch0, but cannot read from Ch17 (I got value from Ch0 instead). If I configure it to read from Ch0 and Ch17 using DMA, values in DMA array are not changing at all.
I share cube-generated MX_ADC1_Init below
static void MX_ADC1_Init(void)
{
/* USER CODE BEGIN ADC1_Init 0 */
/* USER CODE END ADC1_Init 0 */
ADC_ChannelConfTypeDef sConfig = {0};
/* USER CODE BEGIN ADC1_Init 1 */
/* USER CODE END ADC1_Init 1 */
/** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
*/
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.ScanConvMode = ADC_SCAN_SEQ_FIXED;
hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.LowPowerAutoPowerOff = DISABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.NbrOfConversion = 1;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.DMAContinuousRequests = DISABLE;
hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc1.Init.SamplingTimeCommon1 = ADC_SAMPLETIME_160CYCLES_5;
hadc1.Init.OversamplingMode = DISABLE;
hadc1.Init.TriggerFrequencyMode = ADC_TRIGGER_FREQ_LOW;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_0;
sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_17;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN ADC1_Init 2 */
/* USER CODE END ADC1_Init 2 */
}
I couldn't find any example how to use ADC with "not fully configurable sequencer". I can live with polling for Ch0 and Ch17 separately, but also have no clue how to make it work.
Best regards
2022-07-21 06:33 AM
> I couldn't find any example how to use ADC with "not fully configurable sequencer". I
IMO the description in Channel selection subchapter of ADC chapter is fairly comprehensible, so if it can't be clicked in CubeMX, just go and program it using registers.
JW
2022-10-02 06:52 AM
Hi,
Same problem here.
have you found a solution?
I'm using STM32G041J6M6 chip, and trying to read from ADC1 channel 11 & from channel 16. when channel 11 gives good value, but when reading from channel 16 sometimes it gives me the right answer and sometimes it gives me the value in ch11.
any help would be appreciated!
EB