2019-09-17 01:43 AM
I Wanted to generate the microsecond delay function, I have tried below functions but these are not working, It will be good if someone knows the delay function.
static inline void delay_us( uint32_t micros)
{
micros *= (SystemCoreClock / 1000000) / 5;
while (micros);
}
********************
void delay_us( uint32_t us)
{
volatile uint32_t counter = 7*us;
while(counter--)
}
************************
void delay_us( uint32_t value)
{
SysTick->VAL = 8 * value;
uint32_t temp = SysTick->VAL;
while(temp) { temp = SysTick->VAL; }
}
2019-09-17 02:03 AM
Some of the above look broken.
Why can't you use the count value of a free running TIM, at 1 MHz , or faster?
2019-09-17 02:16 AM
Thank u very much.
can i generate it upto below 1 us ?
2019-09-17 02:38 AM
If you clock at CPU speed and account for entry/exit costs, you can achieve sub-microsecond timing.
Interrupt servicing will obviously distort that depending where you use the delay function.
2019-09-17 02:45 AM
Thank u..I will try it
2019-09-18 03:21 AM
can you share code snippet please?
I am trying but it is not working properly?