cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F2xx TIMER->ADC3->DMA->Interrupt

Asantos
Senior
Posted on September 13, 2011 at 13:25

I'm trying to use TIM1 to trigger the ADC3 to trigger DMA to trigger DMA ISR, with the code bellow, the problem is that the interrupt only occurs once.

ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;

ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;

ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;

ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;

ADC_CommonInit(&ADC_CommonInitStructure);

ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;

ADC_InitStructure.ADC_ScanConvMode = ENABLE;

ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;

ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1;

ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_Rising;

ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;

ADC_InitStructure.ADC_NbrOfConversion = 4;

ADC_Init(ADC3, &ADC_InitStructure);

ADC_RegularChannelConfig(ADC3, ADC_Channel_10, 1, ADC_SampleTime_3Cycles);

ADC_RegularChannelConfig(ADC3, ADC_Channel_11, 2, ADC_SampleTime_3Cycles);

ADC_RegularChannelConfig(ADC3, ADC_Channel_12, 3, ADC_SampleTime_3Cycles);

ADC_RegularChannelConfig(ADC3, ADC_Channel_13, 4, ADC_SampleTime_3Cycles);

ADC_DMARequestAfterLastTransferCmd(ADC3, ENABLE);

ADC_DMACmd(ADC3, ENABLE);

ADC_Cmd(ADC3, ENABLE);

DMA_InitStructure.DMA_Channel = DMA_Channel_2;

DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&ADC3buf;

DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC_CCR_ADDRESS;

DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;

DMA_InitStructure.DMA_BufferSize = 4;

DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;

DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;

DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;

DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;

DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;

DMA_InitStructure.DMA_Priority = DMA_Priority_High;

DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable;

DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;

DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;

DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;

DMA_Init(DMA2_Stream1, &DMA_InitStructure);

DMA_Cmd(DMA2_Stream1, ENABLE);

DMA_ITConfig(DMA2_Stream1, DMA_IT_TC, ENABLE);

void

DMA2_Stream1_IRQHandler(

void

)

{

DMA2->LIFCR = 0xFFFFFFFF;

}

1 REPLY 1
infoinfo989
Associate III
Posted on September 16, 2011 at 06:35

You're not showing how you set up your timer. If it only generates one trigger to the ADC, then that might be your problem.

Regardless, I suggest you find some way to physically check the output of your timer. Ideally by routing its output to a GPIO pin, where you can look at it with a scope to confirm it's what you expect. Failing that, perhaps have it generate a timer interrupt, which you can then count to confirm it's running at the expected rate.