AnsweredAssumed Answered

DMA irqHandler doesn't work

Question asked by Damiano Balzani on Feb 15, 2018
Latest reply on Feb 22, 2018 by Damiano Balzani

Hi everyone,

I'm tryng to use DMA with ADC on STM32L051x6 MCU.

 

When i see the Memory dump at the memory address of variable i takes the correct value from ADC DR but DMAIrq doesn't work never

 

Can somebody help me?

Thanks in advance

bool LED_CURRENT_ADC_Init(void)
{
   LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1); //Enable DMA Clock
   DMA1_CSELR -> CSELR &= 0xFFFFFFF0; //Remap of DMA channels to ADC
   LL_ADC_REG_SetDMATransfer(ADC1, LL_ADC_REG_DMA_TRANSFER_UNLIMITED); //Enable DMA    transfer on ADC
   DMA1_Channel1 -> CPAR = (uint32_t) (&(ADC1->DR)); //Configure the ADC data register address
   DMA1_Channel1->CMAR = (uint32_t)(ADC_val); //Configure the memory address
   DMA1_Channel1->CNDTR = 1; //Configure the number of DMA tranfer to be performs on channel 1
   LL_DMA_SetChannelPriorityLevel (DMA1, LL_DMA_CHANNEL_1, LL_DMA_PRIORITY_VERYHIGH); 
   LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MODE_CIRCULAR); //Set mode    LL_DMA_MODE_NORMAL LL_DMA_MODE_CIRCULAR
   LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_1,    LL_DMA_DIRECTION_PERIPH_TO_MEMORY); //Set direction
   LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MDATAALIGN_WORD); //Set dimension
   LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MEMORY_INCREMENT); 
   LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PERIPH_NOINCREMENT); 
   LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PDATAALIGN_HALFWORD); 
   LL_DMA_EnableIT_TC(DMA1, LL_DMA_CHANNEL_1);
   LL_DMA_EnableIT_TE(DMA1, LL_DMA_CHANNEL_1);

   LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_1);
   NVIC_EnableIRQ(DMA1_Channel1_IRQn);
   NVIC_SetPriority(DMA1_Channel1_IRQn, 1);

 

LL_ADC_SetClock(ADC1, LL_ADC_CLOCK_SYNC_PCLK_DIV1);
LL_ADC_SetSamplingTimeCommonChannels(ADC1, LL_ADC_SAMPLINGTIME_7CYCLES_5);
LL_ADC_SetResolution(ADC1, LL_ADC_RESOLUTION_12B);
LL_ADC_SetDataAlignment(ADC1, LL_ADC_DATA_ALIGN_RIGHT);
LL_ADC_REG_SetSequencerChannels(ADC1, LL_ADC_CHANNEL_3);
LL_ADC_REG_SetContinuousMode(ADC1, LL_ADC_REG_CONV_SINGLE); //LL_ADC_REG_CONV_SINGLE LL_ADC_REG_CONV_CONTINUOUS
LL_ADC_ClearFlag_ADRDY(ADC1);
LL_ADC_EnableIT_EOS(ADC1);

LL_ADC_Enable(ADC1);

while(!LL_ADC_IsActiveFlag_ADRDY(ADC1))
{

}


return true;
}

Outcomes