ADC DMA Timer trigger affects only the first callback
Hi,
I'm using STM32F722RET, and I'm trying to do ADC sampling of 3 channels using DMA with a timer trigger.
I configured the following:
ADC:
hadc1.Instance = ADC1;
hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
hadc1.Init.ContinuousConvMode = ENABLE;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T1_TRGO;
hadc1.Init.NbrOfConversion = 3;
hadc1.Init.DMAContinuousRequests = ENABLE;
hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV;
sConfig.Channel = ADC_CHANNEL_0;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES;
sConfig.Channel = ADC_CHANNEL_1;
sConfig.Rank = ADC_REGULAR_RANK_2;
sConfig.Channel = ADC_CHANNEL_2;
sConfig.Rank = ADC_REGULAR_RANK_3;TIMER:
htim1.Instance = TIM1;
htim1.Init.Prescaler = 27000;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 1000;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_UPDATE;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;APB1 Timer clocks: 54MHz
APB2 Timer clocks: 27MHz
But the problem is that only the first callback is triggered in the expected time, and the following ones are too fast. Here are the callback times from first to last: {949, 179, 180, 180, 195, 115}.
I'm using cubemx but if there's a solution with or without cubemx it's all good.
Please assist
UPDATE:
I tried enabling the TIM1 update interrupt, and noticed that it's triggered in the correct speed. It's just the ADC timer trigger that is not working well, although we're talking about the same timer (TIM1).
