Page 1 of 1
chThdSleepMicroseconds or GPT or VT timer
Posted: Wed Jan 18, 2017 4:54 am
by ep.hobbyiest
Hi,
I am using ultrasonic sensor (hc-sr04).
I read some threads about creating 10us timing.
chThdSleepMicroseconds - won't create accurate 10us(+/-3 us)
GPT - can create 10us delay
But here i don't have spare GPT timer to use

. can i use VT timer instead. What will be accuracy.
Re: chThdSleepMicroseconds or GPT or VT timer
Posted: Wed Jan 18, 2017 8:46 am
by Giovanni
Hi,
chThdSleepMicroseconds uses virtual timers internally, it is the same thing. Note that anything based on interrupts will not allow an accuracy of +-3uS because of jitter.
You need to use an HW timer with IRQ priority set to zero, something that the HAL does not allow. Those "fast" interrupts have much reduced jitter but you can't call any OS function from the IRQ handler.
Giovanni
Re: chThdSleepMicroseconds or GPT or VT timer
Posted: Mon Apr 03, 2017 7:30 pm
by ep.hobbyiest
Then instead of using timer can I use pwm?
I am thinking to start PWM for one pulse 10us only and later stop the PWM. Because that would be precise than timer. I can spare one time for that.
Is that possible?
Re: chThdSleepMicroseconds or GPT or VT timer
Posted: Mon Apr 03, 2017 9:03 pm
by Giovanni
Hi,
Yes, it is possible.
Giovanni