30us delay with some constraints
Hi
I am using Timer2 with Prescaler 83 and up counter of period 49 to be triggered after every 50us. But I am using an ADC and I want to turn it on every 330us. So after 6 interrupt triggers, I turn on the ADC but I need to generate a 30us delay before each ADC turn ON. I want this to occur infinitely in a loop. I have tried using a counter function as below
void ADC_Delay(uint16_t us)
{
__HAL_TIM_SET_COUNTER(&htim2, 0);
while (__HAL_TIM_GET_COUNTER(&htim2) < us);
}But I am seeing this delay only on the first loop and not getting the delay in subsequent loops before ADC is turned ON. I have tried various methods even using DWT count and I am still facing the same issue. Please help me solve this bug.
Thanks & Regards
Srinivas
Edited by ST moderator to be inline with the community rules especially with the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code
