2022-05-05 02:26 AM
I am trying to read 2 channel ADC with STM32L011F4.
My ADC and DMA settings in cubemx are as follows
my problem is that the DMA only returns the low 8 bit of the last channel.
uint16_t ADC_Reads[2] = {0};
while (1)
{
HAL_ADC_Start_DMA(&hadc,(uint32_t *)ADC_Reads,2);
HAL_Delay(1000);
}
When I write the following code in the DMA IRQ handler, I can read the values.
uint16_t ADCReads[2];
char i=0;
void DMA1_Channel1_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
ADCReads[i] = hadc.Instance->DR;
i = 1-i;
/* USER CODE END DMA1_Channel1_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_adc);
/* USER CODE BEGIN DMA1_Channel1_IRQn 1 */
/* USER CODE END DMA1_Channel1_IRQn 1 */
}
EWARM live watch screen looks like below
Solved! Go to Solution.
2022-05-08 10:50 PM
2022-05-05 03:54 AM
Lots of people had issues wth this, including me.
Try this out:
HAL_ADC_Start_DMA(&hadc,(uint32_t *)ADC_Reads, sizeof(ADC_Reads)/sizeof(ADC_Reads[0]));
or
HAL_ADC_Start_DMA(&hadc,(uint16_t *)ADC_Reads, sizeof(ADC_Reads)/sizeof(ADC_Reads[0]));
2022-05-06 12:36 AM
it didn't work result is same
2022-05-08 10:50 PM
2022-05-08 11:41 PM
select yourself as best answer then