cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7: ADC conversion with transfer by DMA: HAL_ADC_Start_DMA , Destination Buffer address don't get result

Xkang
Associate

ADC:

ADC1_Handler.Instance		=		ADC1;
    ADC1_Handler.Init.ClockPrescaler		=		ADC_CLOCK_SYNC_PCLK_DIV4; 	//4·ÖƵ£¬ADCCLK=PER_CK/4=64/4=16MHZ
    ADC1_Handler.Init.Resolution				=		ADC_RESOLUTION_12B;           	//16λģʽ
    ADC1_Handler.Init.ScanConvMode			=		ENABLE;                    	//·ÇɨÃèģʽ
    ADC1_Handler.Init.EOCSelection			=		ADC_EOC_SINGLE_CONV;       	//¹Ø±ÕEOCÖ�?¶�?
		ADC1_Handler.Init.LowPowerAutoWait	=		DISABLE;					//×Ô¶¯µ�?¹¦ºÄ¹Ø±Õ				
    ADC1_Handler.Init.ContinuousConvMode=		ENABLE;               //¹Ø±Õ�?¬�?øת»»
    ADC1_Handler.Init.NbrOfConversion		=		1;                        //1¸öת»»ÔÚ¹æÔò�?ò�?�?Ö�? Ò²¾�?ÊÇֻת»»¹æÔò�?ò�?�?1 
    ADC1_Handler.Init.DiscontinuousConvMode		=		DISABLE;            //½ûÖ¹²»�?¬�?ø²ÉÑùģʽ
    ADC1_Handler.Init.NbrOfDiscConversion			=		0;                    //²»�?¬�?ø²ÉÑù�?¨µÀÊýΪ0
    ADC1_Handler.Init.ExternalTrigConv				=		ADC_SOFTWARE_START;      //Èí¼þ´¥·¢
    ADC1_Handler.Init.ExternalTrigConvEdge		=		ADC_EXTERNALTRIGCONVEDGE_NONE;//ʹÓÃÈí¼þ´¥·¢
		ADC1_Handler.Init.BoostMode								=		ENABLE;							//BOOTģʽ¹Ø±Õ
		ADC1_Handler.Init.Overrun						=		ADC_OVR_DATA_OVERWRITTEN;			//Ó�?�?µÄÊý¾�?µÄËÀºóÖ±½Ó¸²¸Çµô¾ÉÊý¾�?
		ADC1_Handler.Init.OversamplingMode	=		DISABLE;					//¹ý²ÉÑù¹Ø±Õ
		ADC1_Handler.Init.ConversionDataManagement	=		ADC_CONVERSIONDATA_DR;  //¹æÔò�?¨µÀµÄÊý¾�?½ö½ö±£´æÔÚDR¼Ä´æÆ÷ÀïÃæ
    HAL_ADC_Init(&ADC1_Handler);                                 //³õʼ»¯ 
	
		HAL_ADCEx_Calibration_Start(&ADC1_Handler,ADC_CALIB_OFFSET,ADC_SINGLE_ENDED); //ADC�?£×¼
	
	  ADC1_ChanConf.Channel				=		ADC_CHANNEL_19;                          //�?¨µÀ
    ADC1_ChanConf.Rank					=		ADC_REGULAR_RANK_1;          //1¸ö�?ò�?�?
    ADC1_ChanConf.SamplingTime	=		ADC_SAMPLETIME_64CYCLES_5; //²ÉÑùʱ¼ä       
	  ADC1_ChanConf.SingleDiff		=		ADC_SINGLE_ENDED;  				 //µ¥±ß²É¼¯          		
		ADC1_ChanConf.OffsetNumber	=		ADC_OFFSET_NONE;             	
		ADC1_ChanConf.Offset				=		0;   
    HAL_ADC_ConfigChannel(&ADC1_Handler,&ADC1_ChanConf);        //�?¨µÀÅäÖÃ

DMA:

UART1TxDMA_Handler.Instance				=		DMA_Streamx;                            //Êý¾�?�?÷Ñ¡Ôñ
	  UART1TxDMA_Handler.Init.Request		=		DMA_REQUEST_ADC1;				      //USART1·¢Ë�?DMA
    UART1TxDMA_Handler.Init.Direction	=		DMA_PERIPH_TO_MEMORY;             //´æ´¢Æ÷µ½�?âÉè
    UART1TxDMA_Handler.Init.PeriphInc	=		DMA_PINC_DISABLE;                 //�?âÉè·ÇÔö�?¿Ä£Ê½
    UART1TxDMA_Handler.Init.MemInc		=		DMA_MINC_ENABLE;                     //´æ´¢Æ÷Ôö�?¿Ä£Ê½
    UART1TxDMA_Handler.Init.PeriphDataAlignment		=		DMA_PDATAALIGN_HALFWORD;    //�?âÉèÊý¾�?³¤¶È:8λ
    UART1TxDMA_Handler.Init.MemDataAlignment			=		DMA_PDATAALIGN_HALFWORD;       //´æ´¢Æ÷Êý¾�?³¤¶È:8λ
    UART1TxDMA_Handler.Init.Mode			=		DMA_CIRCULAR;                            //�?âÉè�?÷¿Øģʽ
    UART1TxDMA_Handler.Init.Priority	=		DMA_PRIORITY_HIGH;               //Ö�?µÈÓÅ�?ȼ¶
    UART1TxDMA_Handler.Init.FIFOMode	=		DMA_FIFOMODE_DISABLE;              
    UART1TxDMA_Handler.Init.FIFOThreshold		=		DMA_FIFO_THRESHOLD_FULL;      
    UART1TxDMA_Handler.Init.MemBurst				=		DMA_MBURST_SINGLE;                 //´æ´¢Æ÷�?»·¢µ¥´Î´«Êä
    UART1TxDMA_Handler.Init.PeriphBurst			=		DMA_PBURST_SINGLE;              //�?âÉè�?»·¢µ¥´Î´«Êä
	
    HAL_DMA_DeInit(&UART1TxDMA_Handler);   
    HAL_DMA_Init(&UART1TxDMA_Handler);
        
    __HAL_LINKDMA(&ADC1_Handler,DMA_Handle,UART1TxDMA_Handler);    //½«DMAÓëUSART1�?ª�?µÆðÀ´(·¢Ë�?DMA)

hope you can help me !

Thank you!

1 REPLY 1
chriscole
Associate III

When using DMA on the H7, make sure that you are using RAM_D1 instead of DTCMRAM in your linker script, because DMA cannot access TCM.

-Chris