My system clock is 170 MHz, and my ADC1 clock is asynchronous with a prescaler of 4. This would mean my ADC1 frequency is 42.5 MHz. I have the ADC being triggered by a timer that is fed off the system clock and triggers every 1 millisecond.
ADC config
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV4;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.GainCompensation = 0;
hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.NbrOfConversion = 1;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIG_T3_TRGO;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
hadc1.Init.DMAContinuousRequests = ENABLE;
hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc1.Init.OversamplingMode = DISABLE;
Timer3 config
htim3.Instance = TIM3;
htim3.Init.Prescaler = 1699;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 99;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
The resolution I have set is 12 bits which takes 12.5 clock cycles and the sampling time I selected is 247.5 clock cycles, which would mean a total of 260 clock cycles. If the ADC clock is running at 42.5 MHz, then it should take 6.11 μs to sample. I set a GPIO pin to go high when the 1 ms timer triggers, and then to go low in the HAL_ADC_ConvCpltCallback function. So I am expecting it to go high for 6.11 μs and then go low until the clock triggers again.
Instead, what I am seeing is the pin staying high for 6 ms, not μs. Did I configure something wrong?