This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32H745 Nucleo: ADC with DMA don't work

Hi! I have STM32H745 Nucleo and i want to transfer data from ADC via DMA.

1. At first i write code for ADC with out DMA (ADC3, PF10 in) and it work excellent. I get positive knovlege.

2. At second step i tried to use DMA (DMA1 stream 1, PF10, ADC3), but code don't work.

 It is code with DMA:

void ADC3_DMA_Config(void)

{

 

  GPIO_InitTypeDef         GPIO_InitStruct;

   static DMA_HandleTypeDef DmaHandle;

   /* ADC handler declaration */

 ADC_HandleTypeDef   AdcHandle_singl;

 ADC_ChannelConfTypeDef  sConfig;

 

 __HAL_RCC_GPIOF_CLK_ENABLE() ;

 __HAL_RCC_ADC3_CLK_ENABLE() ;

 __HAL_RCC_ADC_CONFIG(RCC_ADCCLKSOURCE_CLKP);

  __HAL_RCC_DMA1_CLK_ENABLE();

 

      GPIO_InitStruct.Pin = GPIO_PIN_10 ;

   GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);   

 

    DmaHandle.Instance = DMA1_Stream1;

   DmaHandle.Init.Request            = DMA_REQUEST_ADC3;

   DmaHandle.Init.Direction          = DMA_PERIPH_TO_MEMORY;

   DmaHandle.Init.PeriphInc          = DMA_PINC_DISABLE;

   //   DMA1_Stream1->PAR = (uint32_t)&ADC3->DR;

   //   DMA1_Stream1->M0AR = (uint32_t)&ADC1ConvertedValue;

 

   DmaHandle.Init.MemInc             = DMA_MINC_ENABLE;

   DmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;      

   DmaHandle.Init.MemDataAlignment   = DMA_MDATAALIGN_WORD;     

   DmaHandle.Init.Mode               = DMA_CIRCULAR;            

   DmaHandle.Init.Priority           = DMA_PRIORITY_HIGH;

 

   HAL_DMA_DeInit(&DmaHandle);

   HAL_DMA_Init(&DmaHandle);

 

      DMAMUX1_Channel1->CCR|= 115U;; //stream 1 29 ????

      //DMAMUX1_Channel1->CCR = (115u << DMAMUX_CxCR_DMAREQ_ID_Pos);

    DMA1_Stream1->CR |= DMA_SxCR_EN;

 

 AdcHandle_singl.Instance = ADC3;

 

 AdcHandle_singl.Init.ClockPrescaler          = ADC_CLOCK_ASYNC_DIV2;          

 AdcHandle_singl.Init.Resolution              = ADC_RESOLUTION_16B;           

 AdcHandle_singl.Init.ScanConvMode            = DISABLE;                        

 AdcHandle_singl.Init.EOCSelection            = ADC_EOC_SINGLE_CONV;          

 AdcHandle_singl.Init.LowPowerAutoWait        = DISABLE;                       

 AdcHandle_singl.Init.ContinuousConvMode      = ENABLE ;                        

 

 AdcHandle_singl.Init.NbrOfConversion         = 1;                            

 AdcHandle_singl.Init.DiscontinuousConvMode   = DISABLE;                        

 AdcHandle_singl.Init.NbrOfDiscConversion     = 1;                             

 

 AdcHandle_singl.Init.ExternalTrigConv        = ADC_SOFTWARE_START; ;       

 AdcHandle_singl.Init.ExternalTrigConvEdge    = ADC_EXTERNALTRIGCONVEDGE_NONE;

 

 AdcHandle_singl.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR;

 AdcHandle_singl.Init.Overrun                 = ADC_OVR_DATA_OVERWRITTEN;       

 AdcHandle_singl.Init.OversamplingMode        = DISABLE;                        

 

 if (HAL_ADC_Init(&AdcHandle_singl) != HAL_OK)

 {

   ; //Error_Handler();

 }

 

 /* ### - 2 - Start calibration ############################################ */

 if (HAL_ADCEx_Calibration_Start(&AdcHandle_singl, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED) != HAL_OK)

 {

   ; //Error_Handler();

 }

 

  sConfig.Channel     = ADC_CHANNEL_6; //ADC3_CHANNELa;               /* Sampled channel number */

 sConfig.Rank        = ADC_REGULAR_RANK_1;         /* Rank of sampled channel number ADCx_CHANNEL */

 sConfig.SamplingTime = ADC_SAMPLETIME_8CYCLES_5;   /* Minimum sampling time */

 sConfig.SingleDiff  = ADC_SINGLE_ENDED;           /* Single-ended input channel */

 sConfig.OffsetNumber = ADC_OFFSET_NONE;            /* No offset subtraction */

 sConfig.Offset = 0;                                /* Parameter discarded because offset correction is disabled */

 if (HAL_ADC_ConfigChannel(&AdcHandle_singl, &sConfig) != HAL_OK)

 {

   ; //Error_Handler();

 }

  /* ### - 4 - Start conversion in DMA mode ################################# */

 if (HAL_ADC_Start_DMA(&AdcHandle_singl,

                       (uint32_t *)aADCxConvertedData,

                       ADC_CONVERTED_DATA_BUFFER_SIZE

                      ) != HAL_OK)

 {

   ; //Error_Handler();

 }   

 

 

}