HAL_ADC_ConvCpltCallback is called twice
I'm using an STM32F407, I want to use the falling edge of a PWM to trigger the ADC and then with the DMA move the data into a variable. The problem I have is that I am trying to check if the ADC is actually taking samples at the PWM frequency. I am trying with a low frequency (100 Hz) but I have a problem. To check if the ADC actually samples at 100 Hz, inside the HAL_ADC_ConvCpltCallback() function I change the state of a pin and measure it with the oscilloscope. If the frequency is 100Hz, the oscilloscope should measure 50Hz (1 trigger for each falling edge). But on the oscilloscope I see that the signal is not what I expected and when debugging the code I noticed that the HAL_ADC_ConvCpltCallback() function is called 2 times for each trigger signal. That's why the state of the pin changes 2 times (very fast) for each trigger.
This only happens when I use DMA! Anyone know what might be happening?
I attach the code in C, if you need the rest of the files, please tell me! Thanks a lot
