Skip to main content
xpp07
Associate III
October 5, 2020
Solved

Not seeing full DMA Initialization with CubeMx

  • October 5, 2020
  • 1 reply
  • 1095 views

With CubeMx, I've set up the DMA in Circular Mode, Data Width Half Word, Increment Address Memory. When I get the generated code, I only see the code below. Where are the other initialization parameters? Is it because the DMA channel interrupt is enabled that they're hidden?

static void MX_DMA_Init(void)
{
 
 /* DMA controller clock enable */
 __HAL_RCC_DMA1_CLK_ENABLE();
 
 /* DMA interrupt init */
 /* DMA1_Channel1_IRQn interrupt configuration */
 HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
 HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
 
}

In the file stm32g0xx_hal_dma.c , I see the generic initialization routine shown below. But why I don't see it in the generated code?

HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)
{
 /* Check the DMA handle allocation */
 if (hdma == NULL)
 {
 return HAL_ERROR;
 }
 
 /* Check the parameters */
 assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
 assert_param(IS_DMA_DIRECTION(hdma->Init.Direction));
 assert_param(IS_DMA_PERIPHERAL_INC_STATE(hdma->Init.PeriphInc));
 assert_param(IS_DMA_MEMORY_INC_STATE(hdma->Init.MemInc));
 assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(hdma->Init.PeriphDataAlignment));
 assert_param(IS_DMA_MEMORY_DATA_SIZE(hdma->Init.MemDataAlignment));
 assert_param(IS_DMA_MODE(hdma->Init.Mode));
 assert_param(IS_DMA_PRIORITY(hdma->Init.Priority));

This topic has been closed for replies.
Best answer by TDK

DMA initialization is done in the MspInit function of the peripheral that is using DMA.

1 reply

TDK
TDKBest answer
October 5, 2020

DMA initialization is done in the MspInit function of the peripheral that is using DMA.

"If you feel a post has answered your question, please click ""Accept as Solution""."