cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476 multiple channel ADC and DMA issues

Coratron
Associate II
Posted on January 19, 2018 at 10:25

The original post was too long to process during our migration. Please click on the attachment to read the original post.
3 REPLIES 3
T J
Lead
Posted on January 19, 2018 at 12:54

I have an 091, scan mode is on, but continuous conversion is off.

0690X00000604GqQAI.jpg 0690X00000604GlQAI.jpg

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) {

 if(!ADC_ChannelsCounter--) {
 ADC_ChannelsCounter = ADC_ChannelCount;
 HAL_ADC_CompleteCycle = true; // signal foreground to process 
 
 for(int i = 0 ; i < ADC_ChannelCount ; i++) 
 HAL_ADC_Channel_Buffer[ADC_RowCounter][i] = ADC_DMABuffer[i];
 
 }
}�?�?�?�?�?�?�?�?�?�?�?�?�?

Coratron
Associate II
Posted on January 19, 2018 at 13:52

Here is some extra info in case it is useful.

 DMA configuration and ADC GPIO configuration as it is in the source code:

    GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3;

    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

    /* ADC1 DMA Init */

    /* ADC1 Init */

    hdma_adc1.Instance = DMA1_Channel1;

    hdma_adc1.Init.Request = DMA_REQUEST_0;

    hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;

    hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;

    hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;

    hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;

    hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;

    hdma_adc1.Init.Mode = DMA_CIRCULAR;

    hdma_adc1.Init.Priority = DMA_PRIORITY_MEDIUM;

    if (HAL_DMA_Init(&hdma_adc1) != HAL_OK)

    {

      _Error_Handler(__FILE__, __LINE__);

    }

    __HAL_LINKDMA(adcHandle,DMA_Handle,hdma_adc1);

Also I am using the V1.10 pack for the STM32L4 family on cubeMX.

Posted on January 19, 2018 at 13:35

Thanks for the reply T J. Unfortunately if I disable continuous mode, I'll just get one set of results. Only one conversion of the 4 channels takes place (or whatever it is doing since the values should be 4095 0 X X ... and I get X X X X and sometimes 4095 X X X).