2017-11-16 06:09 AM
Hello,
I am trying to sample analog inputs connected to ADC3 (STM32H7) at 4K sampling rate. For this, i have configured ADC3 to be triggered by the rising edge of LPTIM2 output signal.
if (HAL_ADCEx_Calibration_Start(&hadc3, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED) != HAL_OK)
{
Error_Handler();
}
if (HAL_ADC_Start_DMA(&hadc3, (uint32_t *)sampleBufferBase, sampleBufferSize) != HAL_OK)
{
Error_Handler();
}
if (HAL_LPTIM_PWM_Start(&hlptim2, PeriodValue, PulseValue) != HAL_OK)
{
Error_Handler();
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?
And calculated the values for lptim2 as follows:
// using FrequencyOutput = Counter Clock Frequency / (Autoreload + 1)
// where PeriodValue is Autoreload
// 4096Hz = 32768Hz / (Autoreload + 1) ==> Autoreload = 7
#define PeriodValue 7
// Currently we want, for stability, the PWM duty cycle to be 50%
// PulseValue == DutyCycle = 1 - ((PulseValue + 1)/ (Autoreload + 1))
// 0.5 = 1 - ((PulseValue + 1)/ (7 + 1)) ==> PulseValue = 3
#define PulseValue 3�?�?�?�?�?�?�?�?
But when i am looking at the system using segger systemview, i see that i get 5K instead of 4K.
Is this the right way to do it? Am i wrong with the lptim2 values? Is PWM the best candidate for this sort of a task?
Thanks,
Evgeny
#stm32h7 #lptim #stm32-timer-trigger-adc #lptim2 #adc-trigger #adc