2025-05-21 3:58 AM - last edited on 2025-05-21 8:19 AM by mƎALLEm
I have Nucleo-H743ZI, on which two pins are configured for ADC reading { PB0(CH9) & PB1(CH5) }with circular DMA continuous conversion mode, but only PB1 is able to read data when
HAL_ADC_Start_DMA(&hadc1, (uint32_t *)ADC_Data, 2);
starts reading the data in continuous conversion mode,
the configured ADC settings are as follow:
static void MX_ADC1_Init(void)
{
/* USER CODE BEGIN ADC1_Init 0 */
/* USER CODE END ADC1_Init 0 */
ADC_MultiModeTypeDef multimode = {0};
ADC_ChannelConfTypeDef sConfig = {0};
/* USER CODE BEGIN ADC1_Init 1 */
/* USER CODE END ADC1_Init 1 */
/** Common config
*/
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV32;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.ContinuousConvMode = ENABLE;
hadc1.Init.NbrOfConversion = 2;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR;
hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
hadc1.Init.OversamplingMode = DISABLE;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}
/** Configure the ADC multi-mode
*/
multimode.Mode = ADC_MODE_INDEPENDENT;
if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_5;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_810CYCLES_5;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
sConfig.OffsetSignedSaturation = DISABLE;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_9;
sConfig.Rank = ADC_REGULAR_RANK_2;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN ADC1_Init 2 */
/* USER CODE END ADC1_Init 2 */
}
attaching Cube MX photos for better understanding:
2025-05-21 5:48 AM
Hello,
here I am sending an example which should help you with ADC settings. For reading data from ADC channels by DMA in circular mode, there should be some periodic ADC trigger, for example ADC should be periodically triggered by TIMx as it is in attached example.
Try to reconfigure ADC as Continuous conversion DISABLED, External Trigger Conversion Source to Timer 3 Trigger Out event.
DMA set to Half-word Data Width (due to 12-bit resolution)
Configure TIM3 as Clock source Internal, Prescaler to 999, Counter Period 15, Trigger Event Selection TRGO to Update Event.
In program you should first start TIM (HAL_TIM_Base_Start(&htim3);) and than start DMA transfer by HAL_ADC_Start_DMA(&hadc1, (uint32_t *)ADC_Data, 2);
After that every 1ms should be converted one ADC channel and result should be transfer to memory.
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.
2025-05-21 6:02 AM
Are you waiting for the ADC data to be written? Show the code you use to read out data and how you're determining only one channel is working.
2025-05-21 7:45 AM - last edited on 2025-05-21 8:20 AM by mƎALLEm
uint16_t ADC_Data[2] = {0}; (global var)
HAL_ADC_Start_DMA(&hadc1, (uint32_t *)ADC_Data, 2);
im using this to get continuous data in the buffer as this works on the other discovery board(f407)
and im monitoring data in the live expressions its updating for the first value i.e ADC_Data[0] and ADC_Data[1] remains zero even if the pot is configured for right pin, atleast pin should be floating right, its dead zero
2025-05-21 8:08 AM
DMA should be set to half-word if you're using uint16_t values.
2025-05-21 8:12 AM