2025-04-18 4:03 AM
I would like to file a bug report for STM32CubeMX.
During configuration of CORDIC using DMA, I have found the following issue:
In:
void HAL_CORDIC_MspInit(CORDIC_HandleTypeDef* hcordic)
{
if(hcordic->Instance==CORDIC)
{
/* USER CODE BEGIN CORDIC_MspInit 0 */
/* USER CODE END CORDIC_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_CORDIC_CLK_ENABLE();
/* CORDIC DMA Init */
/* CORDIC_WR Init */
hdma_cordic_wr.Instance = DMA1_Stream0;
hdma_cordic_wr.Init.Request = DMA_REQUEST_CORDIC_WRITE;
hdma_cordic_wr.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_cordic_wr.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_cordic_wr.Init.MemInc = DMA_MINC_ENABLE;
hdma_cordic_wr.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_cordic_wr.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_cordic_wr.Init.Mode = DMA_NORMAL;
hdma_cordic_wr.Init.Priority = DMA_PRIORITY_LOW;
hdma_cordic_wr.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma_cordic_wr) != HAL_OK)
{
Error_Handler();
}
__HAL_LINKDMA(hcordic,hdmaOut,hdma_cordic_wr);
/* CORDIC_RD Init */
hdma_cordic_rd.Instance = DMA1_Stream1;
hdma_cordic_rd.Init.Request = DMA_REQUEST_CORDIC_READ;
hdma_cordic_rd.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_cordic_rd.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_cordic_rd.Init.MemInc = DMA_MINC_ENABLE;
hdma_cordic_rd.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_cordic_rd.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_cordic_rd.Init.Mode = DMA_NORMAL;
hdma_cordic_rd.Init.Priority = DMA_PRIORITY_LOW;
hdma_cordic_rd.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma_cordic_rd) != HAL_OK)
{
Error_Handler();
}
__HAL_LINKDMA(hcordic,hdmaIn,hdma_cordic_rd);
/* USER CODE BEGIN CORDIC_MspInit 1 */
/* USER CODE END CORDIC_MspInit 1 */
}
}
The DMA streams are linked to the wrong DMA handles, I had to manually adjust the following to get the CORDIC working with DMA:
__HAL_LINKDMA(hcordic,hdmaOut,hdma_cordic_wr); -> __HAL_LINKDMA(hcordic,hdmaIn,hdma_cordic_wr);
and:
__HAL_LINKDMA(hcordic,hdmaIn,hdma_cordic_rd); -> __HAL_LINKDMA(hcordic,hdmaOut,hdma_cordic_rd);
This issue happens when generating code using STM32CubeMX version 6.14.0. The issue can be reproduced by simply creating a project for the NUCLEO-H723ZG, initializing the CORDIC with the write and read DMA streams enabled and then generating the code.
Note: The CORDIC_Sin_DMA example shows the correct HAL_CORDIC_MspInit function. This example was used to pinpoint why the CORDIC wasn't working in a newly created project.
2025-04-18 4:07 AM
Hello @beauwilmink ,
First let me thank you for posting and welcome to the ST Community.
Your request is under investigation, and I will get back to you ASAP.
Thanks.
Mahmoud
2025-04-18 8:14 AM
Hello @beauwilmink ,
Thank you for binging this issue to our attention.
An internal ticket is raised to the Development team under this number: 208115.
Thanks.
Mahmoud