2023-07-12 02:56 AM
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
2023-07-12 06:14 AM - edited 2023-07-12 06:27 AM
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!
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.
2023-07-13 02:02 AM - edited 2023-07-13 05:22 AM
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);
}
2023-08-03 09:01 AM - edited 2023-08-03 09:02 AM
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
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.