cancel
Showing results for 
Search instead for 
Did you mean: 

Not seeing full DMA Initialization with CubeMx

xpp07
Senior

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));

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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".

View solution in original post

1 REPLY 1
TDK
Guru

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".