Skip to main content
mh_it
Associate II
January 19, 2017
Solved

STM32CubeMX don't generate DMA SW4STM32 code

  • January 19, 2017
  • 1 reply
  • 1755 views
Posted on January 19, 2017 at 01:39

I have setup the STM32CubeMX project.. (STM32F302RExx)

I use the ADC in continues / scan mode.

I have DMAContReq = true..

I then setup DMA on ADC1-CH1 with HIGH prio..

but when i generate my Cube-code... i don't see ANY code for the DMA setup ??

The ADC's works fine if i poll them.

This : 'DMA_HandleTypeDef hdma_adc1;' I see..

but thats IT .. no more references.. i have all in my MainFile..

Any clues ?

/M.H.

p.s..

I'm guessing i am missing something like THIS (THIS IS NOT TO FIND IN CUBE-GENERATED CODE):

hdma_adc1.Instance = DMA1_Channel1;

hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;

hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;

hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;

hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;

hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;

hdma_adc1.Init.Mode = DMA_CIRCULAR;

hdma_adc1.Init.Priority = DMA_PRIORITY_HIGH;

if (HAL_DMA_Init(&hdma_adc1) != HAL_OK)

{

Error_Handler();

}

__HAL_LINKDMA(&hadc1,DMA_Handle,hdma_adc1);

#stm32cubemx*
This topic has been closed for replies.
Best answer by Nesrine M_O
Posted on January 19, 2017 at 10:48

Hi

Holch.Mikkel

‌,

I'm using the 4.19 version,

the ADC

MSP Initialization with DMA configuration isavailableon

stm32f3xx_hal_msp.c file.

The MSP file ( located in your project Src folder) is generated automatically.

-Nesrine-

1 reply

Nesrine M_O
Associate
January 19, 2017
Posted on January 19, 2017 at 09:41

Hi

‌,

Using :

  • CUBEMX version 4.18
  • SW4STM32
  • STM32F302RETX
  • ADC1 in continues mode with DMA enabled

all work as expected and theHAL_ADC_MspInit is generated correctly :

void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc){ GPIO_InitTypeDef GPIO_InitStruct; if(hadc->Instance==ADC1) { /* USER CODE BEGIN ADC1_MspInit 0 */ /* USER CODE END ADC1_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_ADC12_CLK_ENABLE(); /**ADC1 GPIO Configuration PA0 ------> ADC1_IN1 PA1 ------> ADC1_IN2 */ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Peripheral DMA init*/ hdma_adc1.Instance = DMA1_Channel1; hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY; hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE; hdma_adc1.Init.MemInc = DMA_MINC_ENABLE; hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; hdma_adc1.Init.Mode = DMA_NORMAL; hdma_adc1.Init.Priority = DMA_PRIORITY_HIGH; if (HAL_DMA_Init(&hdma_adc1) != HAL_OK) { Error_Handler(); } __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1); /* USER CODE BEGIN ADC1_MspInit 1 */ /* USER CODE END ADC1_MspInit 1 */ }}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

0690X000006060MQAQ.png 0690X000006062cQAA.png

-Nesrine-

mh_it
mh_itAuthor
Associate II
January 19, 2017
Posted on January 19, 2017 at 09:51

hmm... now thats looks funny...

try CubeMx 4.19

and I DON't generate code in seperate C/H files..

but have it all in 1 Main.c

I'm Generating Code UPDATE  the code, because i have added own code..

/M

0690X000006062hQAA.png0690X000006062mQAA.png
Nesrine M_O
Associate
January 19, 2017
Posted on January 19, 2017 at 10:48

Hi

Holch.Mikkel

‌,

I'm using the 4.19 version,

the ADC

MSP Initialization with DMA configuration isavailableon

stm32f3xx_hal_msp.c file.

The MSP file ( located in your project Src folder) is generated automatically.

-Nesrine-