Skip to main content
Visitor II
July 12, 2023
Question

ADC|DMA|TIMER + STM32U575

  • July 12, 2023
  • 2 replies
  • 1871 views

Hello 

I am validating the ADC DMA Timer using stm32u5

I am doing when ADC and DMA are working fine but timer is not working getting into the error handler 

what I am doing is I want start ADC and DMA  when timer trigger but the timer is following error handler I dont know what is Issue anyone aware of these thing let me know ASAP

NOTE:: https://www.youtube.com/watch?v=pLsAhJ8umJk
STM32CUBEIDE basics -10 ADC DMA TIM HAL lab

doing same method but using stm32u5 

 

    This topic has been closed for replies.

    2 replies

    ST Employee
    July 12, 2023

    Hello @PESHWA

    Maybe the issue is related to wrong peripherals settings.

    I propose to debug and localize where the code hangs. Check the registers and flags to detect DMA completion and timer events.

    You can also check this video of triggering ADC conversions by TIM!

    You can share your configuration/code, this will help Community users to understand the issue and help you.

    Hope that helps!

    PESHWAAuthor
    Visitor II
    July 13, 2023

    Hello @Sarra.S 

    yes i have done debug and what you said but thing 

    the flow of code is like this 

    1]  calibration start

    2] ADC _DMA _START

    3] TIMER_Start

    /* Start ADC conversions */
    if (HAL_ADCEx_Calibration_Start(&hadc1,ADC_CALIB_OFFSET, ADC_SINGLE_ENDED) != HAL_OK)
    {
    // /* Calibration Error */
    Error_Handler();
    }



    /* Start ADC group regular conversion with DMA */
    if (HAL_ADC_Start_DMA(&hadc1,
    (uint32_t *)pDmaBuff,
    (dataSize)
    ) != HAL_OK)


    {
    /* ADC conversion start error */
    Error_Handler();
    }

    /* Start Timer trigger */
    if (HAL_TIM_Base_Start(&hadc1) != HAL_OK)
    {
    /* TIM start error */
    Error_Handler();
    }
    }
    return error

     

    Note : I am using DMA with standard request mode 

    One more thing I noticed while debugging I Am using  DMA with standard request mode but while it follow the LINKED_LIST MODE code after check the linked list  mode I dont understand what happening why it following LINKED LIST path 

    if ((hadc->DMA_Handle->Mode & DMA_LINKEDLIST) == DMA_LINKEDLIST)
    {
    if ((hadc->DMA_Handle->LinkedListQueue != NULL) && (hadc->DMA_Handle->LinkedListQueue->Head != NULL))
    {
    /* Length should be converted to number of bytes */
    if (HAL_DMAEx_List_GetNodeConfig(&node_conf, hadc->DMA_Handle->LinkedListQueue->Head) != HAL_OK)
    {
    return HAL_ERROR;
    }

    /* Length should be converted to number of bytes */
    if (node_conf.Init.SrcDataWidth == DMA_SRC_DATAWIDTH_WORD)
    {
    /* Word -> Bytes */
    LengthInBytes = Length * 4U;
    }
    else if (node_conf.Init.SrcDataWidth == DMA_SRC_DATAWIDTH_HALFWORD)
    {
    /* Halfword -> Bytes */
    LengthInBytes = Length * 2U;
    }
    else /* Bytes */
    {
    /* Same size already expressed in Bytes */
    LengthInBytes = Length;
    }

    hadc->DMA_Handle->LinkedListQueue->Head->LinkRegisters[NODE_CBR1_DEFAULT_OFFSET] = (uint32_t)LengthInBytes;
    hadc->DMA_Handle->LinkedListQueue->Head->LinkRegisters[NODE_CSAR_DEFAULT_OFFSET] = \
    (uint32_t)&hadc->Instance->DR;
    hadc->DMA_Handle->LinkedListQueue->Head->LinkRegisters[NODE_CDAR_DEFAULT_OFFSET] = (uint32_t)pData;
    tmp_hal_status = HAL_DMAEx_List_Start_IT(hadc->DMA_Handle);
    }
    else
    {
    tmp_hal_status = HAL_ERROR;
    }
    }
    else
    {
    /* Length should be converted to number of bytes */
    if (hadc->DMA_Handle->Init.SrcDataWidth == DMA_SRC_DATAWIDTH_WORD)
    {
    /* Word -> Bytes */
    LengthInBytes = Length * 4U;
    }
    else if (hadc->DMA_Handle->Init.SrcDataWidth == DMA_SRC_DATAWIDTH_HALFWORD)
    {
    /* Halfword -> Bytes */
    LengthInBytes = Length * 2U;
    }
    else /* Bytes */
    {
    /* Same size already expressed in Bytes */
    LengthInBytes = Length;
    }

    tmp_hal_status = HAL_DMA_Start_IT(hadc->DMA_Handle, (uint32_t)&hadc->Instance->DR, (uint32_t)pData, \
    LengthInBytes);
    }

    /* Enable conversion of regular group. */
    /* If software start has been selected, conversion starts immediately. */
    /* If external trigger has been selected, conversion will start at next */
    /* trigger event. */
    /* Start ADC group regular conversion */
    LL_ADC_REG_StartConversion(hadc->Instance);
    }

     

    Explorer II
    February 18, 2025

    Hello, 

     

    Did you solve your issue? I would  like to implement something similar in my application ...

     

    How did you issue evolved?

     

    Thank you,

     

    Marc

    ST Employee
    August 3, 2023

    Hello @PESHWA

    I don't think this part of the code is causing the problem, could you please share your DMA configuration, precisely the DMA_InitTypeDef structure hdma_adc and the HAL_DMA_Init() function?

    Sorry for the late response