AnsweredAssumed Answered

Timer2 channel 3+ADC+DMA

Question asked by Balasubramanian vaidhyanathan on Oct 20, 2017
Latest reply on Oct 23, 2017 by Balasubramanian vaidhyanathan

Hi

 

    I am using STM32L431xx Timer3 and CC3 (compare mode ) on channel 3 and i want to trigger (ADC1  channel 1) and (DMA 1 and channel 1 ) to do collection of samples triggered on the timer edge. The timer works perfectly fine for the period I have set it work on. But I am not able to get the ADC->DMA chain working with the timer. Below are the ADC settings :

 

LL_ADC_SetCommonPathInternalCh(ADC1_COMMON,LL_ADC_PATH_INTERNAL_VREFINT);
LL_ADC_SetCommonClock(ADC1_COMMON,LL_ADC_CLOCK_SYNC_PCLK_DIV4);
LL_ADC_SetResolution(ADC1, LL_ADC_RESOLUTION_12B);
LL_ADC_SetOffset(ADC1, LL_ADC_OFFSET_1, LL_ADC_CHANNEL_1, 0x000);
LL_ADC_SetOffsetState(ADC1, LL_ADC_OFFSET_1,LL_ADC_OFFSET_DISABLE);
LL_ADC_SetChannelSamplingTime(ADC1,LL_ADC_CHANNEL_1, LL_ADC_SAMPLINGTIME_12CYCLES_5);
LL_ADC_REG_SetDMATransfer(ADC1,LL_ADC_REG_DMA_TRANSFER_UNLIMITED);
LL_ADC_REG_SetContinuousMode(ADC1, LL_ADC_REG_CONV_CONTINUOUS);
LL_ADC_REG_SetTriggerSource(ADC1,LL_ADC_REG_TRIG_EXT_TIM2_TRGO);
LL_ADC_Enable(ADC1);

 

DMA settings

 

LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1);

 

 

DMA_cfg.CPAR = (uint32_t)&ADC1->DR;
DMA_cfg.CMAR = (uint32_t)destAddress;//destinatoin address


DMA_cfg.CNDTR = numData;//number of bytes to be trasnferred

 

DMA1_Channel1->CCR = ( DMA_CCR_TCIE | DMA_CCR_TEIE | DMA_CCR_CIRC | DMA_CCR_HTIE| DMA_CCR_MINC | DMA_CCR_PSIZE_32BIT | DMA_CCR_MSIZE_32BIT | DMA_CCR_PL_VERY_HIGH ) 

 


DMA1_CSELR->CSELR = DMA1_CFG_CSELR; \\this value is '0'
NVIC_SetPriority(DMA1_Channel1_IRQn, 0);
NVIC_EnableIRQ(DMA1_Channel1_IRQn);
LL_DMA_EnableChannel(DMA1,LL_DMA_CHANNEL_1);

 

I dont see that I am able to get the ADC to trigger so that transfer happens!!!

 

 

Please help!

 

Regards

Bala

Outcomes