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.
chThdSleepMicroseconds or GPT or VT timer
Moderators: RoccoMarco, barthess
-
- Posts: 94
- Joined: Sun Jun 26, 2016 5:22 pm
- Has thanked: 4 times
- Been thanked: 1 time
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: chThdSleepMicroseconds or GPT or VT timer
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
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
-
- Posts: 94
- Joined: Sun Jun 26, 2016 5:22 pm
- Has thanked: 4 times
- Been thanked: 1 time
Re: chThdSleepMicroseconds or GPT or VT timer
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?
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?
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Who is online
Users browsing this forum: No registered users and 44 guests