cancel
Showing results for 
Search instead for 
Did you mean: 

I can not start ADC with cyclic data transfer via DMA to stm32h743.

Alex Golubev
Associate II

Hi.

Here is my code:

	MODIFY_REG(RCC->D3CCIPR, RCC_D3CCIPR_ADCSEL, 0 << RCC_D3CCIPR_ADCSEL_Pos);
	RCC->AHB1ENR |= RCC_AHB1ENR_ADC12EN; 
	DMAMUX1_Channel0->CCR = (9 << DMAMUX_CxCR_DMAREQ_ID_Pos); // подключение через MUXDMA DMA1_�?трим_0 к ADC1
 
	DMA1_Stream0->CR &= ~DMA_SxCR_EN; 
	while(DMA1_Stream0->CR & DMA_SxCR_EN); 
	DMA1_Stream0->CR = DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_CIRC | DMA_SxCR_DIR_0;
	DMA1_Stream0->NDTR = 5;
	DMA1_Stream0->PAR = (uint32_t)&ADC1->DR; 
	DMA1_Stream0->M0AR = (uint32_t)&bufAdcData; 
 
 
	ADC12_COMMON->CCR = ADC_CCR_VBATEN
			| ADC_CCR_TSEN
			| ADC_CCR_VREFEN
			| ADC_CCR_PRESC_0 | ADC_CCR_PRESC_1 | ADC_CCR_PRESC_2 | ADC_CCR_PRESC_3
			| ADC_CCR_CKMODE_0; 
 
	ADC1->CR &= ~ADC_CR_DEEPPWD; 
	ADC1->CR |= ADC_CR_ADVREGEN; 
	while(!(ADC1->ISR & (1<<12))); 
	ADC1->CR |= ADC_CR_ADEN; 
	while(ADC1->IER & ADC_ISR_ADRDY); 
	ADC1->CR |= ADC_CR_ADCAL;
	while(!(ADC1->CR & ADC_CR_ADCAL)); 
    ADC1->CFGR = ADC_CFGR_JQDIS | (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_0) | ADC_CFGR_DISCEN | ADC_CFGR_CONT | ADC_CFGR_DMNGT_1 | ADC_CFGR_DMNGT_0; 
	ADC1->CFGR2 = 0;
	ADC1->SMPR1 = ADC_SMPR1_SMP9_2 | ADC_SMPR1_SMP3_2; 
	ADC1->SMPR2 = ADC_SMPR2_SMP19_2 | ADC_SMPR2_SMP18_2 | ADC_SMPR2_SMP15_2;
	ADC1->PCSEL = ADC_PCSEL_PCSEL_19 | ADC_PCSEL_PCSEL_18 | ADC_PCSEL_PCSEL_15 | ADC_PCSEL_PCSEL_9 | ADC_PCSEL_PCSEL_3; // 19,18,15,9,3
	ADC1->LTR1 = 0x00;
	ADC1->LTR2 = 0x00;
	ADC1->LTR3 = 0x00;
	ADC1->HTR1 = 0x00;
	ADC1->HTR2 = 0x00;
	ADC1->HTR3 = 0x00;
 
	ADC1->SQR1 = (ADC_SQR1_SQ1_1 | ADC_SQR1_SQ1_0)
			| (ADC_SQR1_SQ2_3 |  ADC_SQR1_SQ2_0)
			| (ADC_SQR1_SQ3_3 | ADC_SQR1_SQ3_2 | ADC_SQR1_SQ3_1 | ADC_SQR1_SQ3_0)
			| (ADC_SQR1_SQ4_4 | ADC_SQR1_SQ4_1); 
 
	ADC1->SQR2 = (ADC_SQR2_SQ5_4 | ADC_SQR2_SQ5_1 | ADC_SQR2_SQ5_0); 
	ADC1->SQR3 = 0;
	ADC1->SQR4 = 0;
	DMA1_Stream0->CR |= DMA_SxCR_EN;
	while(!(DMA1_Stream0->CR & DMA_SxCR_EN)); 
 
	MODIFY_REG(GPIOA->MODER, GPIO_MODER_MODE3, 0x3 << GPIO_MODER_MODE3_Pos); 
	MODIFY_REG(GPIOA->MODER, GPIO_MODER_MODE4, 0x3 << GPIO_MODER_MODE4_Pos); 
	MODIFY_REG(GPIOA->MODER, GPIO_MODER_MODE5, 0x3 << GPIO_MODER_MODE5_Pos); 
	MODIFY_REG(GPIOA->MODER, GPIO_MODER_MODE6, 0x3 << GPIO_MODER_MODE6_Pos);
	MODIFY_REG(GPIOB->MODER, GPIO_MODER_MODE0, 0x3 << GPIO_MODER_MODE0_Pos);
 
	MODIFY_REG(GPIOA->OSPEEDR, GPIO_OSPEEDR_OSPEED3,0x0 << GPIO_OSPEEDR_OSPEED3_Pos); 
	MODIFY_REG(GPIOA->OSPEEDR, GPIO_OSPEEDR_OSPEED4,0x0 << GPIO_OSPEEDR_OSPEED4_Pos);
	MODIFY_REG(GPIOA->OSPEEDR, GPIO_OSPEEDR_OSPEED5,0x0 << GPIO_OSPEEDR_OSPEED5_Pos);
	MODIFY_REG(GPIOA->OSPEEDR, GPIO_OSPEEDR_OSPEED6,0x0 << GPIO_OSPEEDR_OSPEED6_Pos);
	MODIFY_REG(GPIOB->OSPEEDR, GPIO_OSPEEDR_OSPEED0,0x0 << GPIO_OSPEEDR_OSPEED0_Pos);
 
	MODIFY_REG(GPIOA->PUPDR, GPIO_PUPDR_PUPD3, 0x00 << GPIO_PUPDR_PUPD3_Pos);
	MODIFY_REG(GPIOA->PUPDR, GPIO_PUPDR_PUPD4, 0x00 << GPIO_PUPDR_PUPD4_Pos);
	MODIFY_REG(GPIOA->PUPDR, GPIO_PUPDR_PUPD5, 0x00 << GPIO_PUPDR_PUPD5_Pos);
	MODIFY_REG(GPIOA->PUPDR, GPIO_PUPDR_PUPD6, 0x00 << GPIO_PUPDR_PUPD6_Pos); 
	MODIFY_REG(GPIOB->PUPDR, GPIO_PUPDR_PUPD0, 0x00 << GPIO_PUPDR_PUPD0_Pos);
 
	MODIFY_REG(GPIOA->AFR[0], GPIO_AFRL_AFSEL3, 0x0 << GPIO_AFRL_AFSEL3_Pos); 
	MODIFY_REG(GPIOA->AFR[0], GPIO_AFRL_AFSEL4, 0x0 << GPIO_AFRL_AFSEL4_Pos); 
	MODIFY_REG(GPIOA->AFR[0], GPIO_AFRL_AFSEL5, 0x0 << GPIO_AFRL_AFSEL5_Pos);
	MODIFY_REG(GPIOA->AFR[0], GPIO_AFRL_AFSEL6, 0x0 << GPIO_AFRL_AFSEL6_Pos);
	MODIFY_REG(GPIOB->AFR[0], GPIO_AFRL_AFSEL0, 0x0 << GPIO_AFRL_AFSEL0_Pos); 
 
	ADC1->CR |= ADC_CR_ADSTART;
 

All data in the buffer are zeros.

What am I doing wrong?

0 REPLIES 0