Skip to main content
spa23
Associate III
April 13, 2015
Question

cubeMx, DMA and Adc

  • April 13, 2015
  • 3 replies
  • 1145 views
Posted on April 13, 2015 at 14:17

HI

I just have a simple question; I think I�m missing something.

I using cubeMX for getting the ADC up running with 2 ch ( IN8 and IN15)

And the DMA for transferring the data to a buffer.

I have added a picture showing the cubeMX ADC setup

And I Use the:

if( HAL_ADC_Start_DMA( mpHadc, (uint32_t *)rawAnalogData, 4 ) == HAL_OK )

For starting the ADC.

And I have implemented the:

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)

{

                             analogConvDone = true;

                             HAL_ADC_Stop_DMA(mpHadc);

}

The problem is that I only get data from ch8 (rank 1) and NOT from ch15

Hops someone can give a hint.

#adc-dma-cubemx
This topic has been closed for replies.

3 replies

spa23
spa23Author
Associate III
April 14, 2015
Posted on April 14, 2015 at 08:39

HI 

It seems to be a error in the ADC software for cubeMx. continuous mode does not work.

When you set continuous mode to enable (in cubeMX) it only just convert the first rank.

example:

/* ADC1 init function */

void MX_ADC1_Init(void)

{

  ADC_ChannelConfTypeDef sConfig;

    /**Common config 

    */

  hadc1.Instance = ADC1;

  hadc1.Init.ScanConvMode = ENABLE;

  hadc1.Init.ContinuousConvMode = ENABLE;

  hadc1.Init.DiscontinuousConvMode = DISABLE;

  hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;

  hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;

  hadc1.Init.NbrOfConversion = 4;

  HAL_ADC_Init(&hadc1);

    /**Configure Regular Channel 

    */

  sConfig.Channel = ADC_CHANNEL_8;

  sConfig.Rank = 1;

  sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;

  HAL_ADC_ConfigChannel(&hadc1, &sConfig);

    /**Configure Regular Channel 

    */

  sConfig.Channel = ADC_CHANNEL_15;

  sConfig.Rank = 2;

  HAL_ADC_ConfigChannel(&hadc1, &sConfig);

    /**Configure Regular Channel 

    */

  sConfig.Channel = ADC_CHANNEL_TEMPSENSOR;

  sConfig.Rank = 3;

  HAL_ADC_ConfigChannel(&hadc1, &sConfig);

    /**Configure Regular Channel 

    */

  sConfig.Channel = ADC_CHANNEL_VREFINT;

  sConfig.Rank = 4;

  HAL_ADC_ConfigChannel(&hadc1, &sConfig);

}

And in HAL_ADC_Init()

    if (hadc->Init.ScanConvMode == ADC_SCAN_ENABLE)

    {

      tmp_sqr1 = ADC_SQR1_L_SHIFT(hadc->Init.NbrOfConversion);

    }

Problem in Init.ScanConvMode:  ADC_SCAN_ENABLE and ENABLE is not the same value!!

Best regards

Søren Panduro

I have tried to post a ticket in the online support, but it keeps telling me: The submit action was successfully cancelled. -> super

L

Amel NASRI
Technical Moderator
April 22, 2015
Posted on April 22, 2015 at 10:35

Hipanduro.soeren.002,

This issue has been reported in following threads:

-

https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/STMCubeMX%20Incorrect%20ADC%20generation%20for%20STM32103CBT6

-

https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Bug%20report%20Stm32cubeMX%20ADC%20initialization%20code%28%20Cube%20v4.6.0stm32f1xx_hal_adc.c%28v1.0.0%29

It should be already fixed in current CubeMX release (4.7).

So, could you please let me know if you are using this one or a previous version?

If 4.7 is used, please tell me what product are you using.

Thanks

-Mayla-

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.
nick239955_stm1_stmicro
Visitor II
November 24, 2016
Posted on November 24, 2016 at 01:41

This still occurs on the STM32F746VGTx and the latest FW-F7 (V1.5.0 and V1.5.1) do not generate valid Atollic TrueStudio projects.

Nick