2015-11-27 08:10 AM
Hello,
I'm using IAR & cubeMX, and the nucleo board6 regular channels, no injection :1/ internal TS2/ A8 (connected to OPAMP 1) forced at 3.3V3/ A9 forced at 3.3V4/ A15 (connected to OPAMP 2) forced at 3.3/2 (voltage divider with 2R)5/ internal vbat6/ vrefI'm not concerned about speed. I performed a calibration with HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);Internal channels are working, but external channels are not. The ADC returns something between 400 and 700 (@12bits).I can change the order of measurments, measure only output channel, measure multiple time the same input, in all case, all order, external channel returns floating values between 400 and 700.I call the ADC conversion fuction every second with : HAL_ADC_Start_DMA(&hadc1, (uint32_t*)temp, 6);@main() : MX_ADC1_Init(); hadc1.Instance->CFGR = 0x80000000; HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);@adc.c :void MX_ADC1_Init(void){ ADC_ChannelConfTypeDef sConfig; /**Common config */ hadc1.Instance = ADC1; hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV2; hadc1.Init.Resolution = ADC_RESOLUTION_12B; hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; hadc1.Init.LowPowerAutoWait = ENABLE; hadc1.Init.ContinuousConvMode = DISABLE; hadc1.Init.NbrOfConversion = 6; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; hadc1.Init.DMAContinuousRequests = DISABLE; hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; hadc1.Init.OversamplingMode = DISABLE; HAL_ADC_Init(&hadc1); /**Configure Regular Channel */ sConfig.Channel = ADC_CHANNEL_TEMPSENSOR; sConfig.Rank = 1; sConfig.SamplingTime = ADC_SAMPLETIME_640CYCLES_5; sConfig.SingleDiff = ADC_SINGLE_ENDED; sConfig.OffsetNumber = ADC_OFFSET_NONE; sConfig.Offset = 0; HAL_ADC_ConfigChannel(&hadc1, &sConfig); /**Configure Regular Channel */ sConfig.Channel = ADC_CHANNEL_8; sConfig.Rank = 2; HAL_ADC_ConfigChannel(&hadc1, &sConfig); /**Configure Regular Channel */ sConfig.Channel = ADC_CHANNEL_9; sConfig.Rank = 3; HAL_ADC_ConfigChannel(&hadc1, &sConfig); /**Configure Regular Channel */ sConfig.Channel = ADC_CHANNEL_15; sConfig.Rank = 4; HAL_ADC_ConfigChannel(&hadc1, &sConfig); /**Configure Regular Channel */ sConfig.Channel = ADC_CHANNEL_VBAT; sConfig.Rank = 5; HAL_ADC_ConfigChannel(&hadc1, &sConfig); /**Configure Regular Channel */ sConfig.Channel = ADC_CHANNEL_VREFINT; sConfig.Rank = 6; HAL_ADC_ConfigChannel(&hadc1, &sConfig);}2015-11-30 07:03 AM
2015-12-01 08:35 AM
Chris T, thank you so much!
- ADC.IN9 was wrongly configured by the STM32L4 FW package v1.0.0. I updated it yesterday for other reasons, and now ADC.IN9 is working.- Reading your message, I immediately looked at the 2 other inputs. There are configured in opamp.c as GPIO_MODE_ANALOG instead of GPIO_MODE_ANALOG_ADC_CONTROL, even if the opamp output is routed to ADC in cubeMX.I hope ST will quickly solve this bug because it may be time-consuming :)With the correction, my ADC now work fine.2015-12-02 06:45 AM
Hi bonelli,
The reported issue regarding the mode selected for ADC pins should be already fixed in CubeMX 4.11.Are you using an older version?-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.