STM32F0 ADC DMA Assistance
Hello All,
Hoping someone can help me understand the ADC DMA via ST's HAL. I haven't been able to locate the information I need to understand how it works or what I have read still doesn't give me what I need so if someone refers me to the proper doc I'll take a RTFM response if it clearly gives me the understanding I am looking for.
Essentially I have 4 ADC's (in 12 bit resolution mode) and I am trying capture that data and convert it (ie temp, moisture, ect..). Trying to understand how the API works for the DMA conversion and how my 4 ADC channels align in my assigned pointer. Below outlines what I currently have set up, and highlighted in red text is where my confusion is.
I am using the STM32F072RB custom board design, used CubeMX to set up the ADC:
Below is called in my main function:
if (HAL_ADC_Start_DMA(&hadc, (uint32_t*)ADC1ConvertedValues,
1024
) != HAL_OK) return 0;Below is in my while loop:
sprintf((char *)str, ''ADC Val: %d %d %d %d\r\n'', ADC1ConvertedValues[
0
], ADC1ConvertedValues[1
], ADC1ConvertedValues[2
], ADC1ConvertedValues[3
]); // Want my 4 ADC channels to print the individual ADC value read. len = strlen((char *)str); HAL_UART_Transmit(&huart2, str, len, 1000);Debugger Watch result:

/* ADC init function */
static void MX_ADC_Init(void){ADC_ChannelConfTypeDef sConfig;
/**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
*/ hadc.Instance = ADC1; hadc.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; hadc.Init.Resolution = ADC_RESOLUTION_12B; hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT; hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD; hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV; hadc.Init.LowPowerAutoWait = DISABLE; hadc.Init.LowPowerAutoPowerOff = DISABLE; hadc.Init.ContinuousConvMode = ENABLE; hadc.Init.DiscontinuousConvMode = DISABLE; hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; hadc.Init.DMAContinuousRequests = ENABLE; hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED; if (HAL_ADC_Init(&hadc) != HAL_OK) { Error_Handler(); }/**Configure for the selected ADC regular channel to be converted.
*/ sConfig.Channel = ADC_CHANNEL_4; sConfig.Rank = ADC_RANK_CHANNEL_NUMBER; sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK) { Error_Handler(); }/**Configure for the selected ADC regular channel to be converted.
*/ sConfig.Channel = ADC_CHANNEL_10; if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK) { Error_Handler(); }/**Configure for the selected ADC regular channel to be converted.
*/ sConfig.Channel = ADC_CHANNEL_11; if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK) { Error_Handler(); }/**Configure for the selected ADC regular channel to be converted.
*/ sConfig.Channel = ADC_CHANNEL_12; if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK) { Error_Handler(); }}
#adc