change frequency of PWM for TIMER on STM32F429I

Hi

I am working on changing the frequency of the square signal which comes from STM32F4. I used Timer and ADC simultaneously where I change ARR and CCR1 accordingly to change the frequency. When I use an incremental loop for these values I can get different frequency but When I add ADC (continuous mode) in the fly of the program, the output gives me just one frequency and when I press the reset button with changing variable resistor I get updated value. How can I solve this issue? Is there another method to do that?

this is my code:

-----------------------------------------------------------------------

while (1)
{

AA=HAL_ADC_GetValue(&hadc1);
DT=0.5*AA;


htim3.Instance->ARR=AA;
htim3.Instance->CCR1=DT;
}

-------------------------------------------------------------------------

I will hear from you.

Thanks

More questions in this forum