chThdSleepMicroseconds or GPT or VT timer

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

ep.hobbyiest
Posts: 94
Joined: Sun Jun 26, 2016 5:22 pm
Has thanked: 4 times
Been thanked: 1 time

chThdSleepMicroseconds or GPT or VT timer

Postby ep.hobbyiest » Wed Jan 18, 2017 4:54 am

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.

User avatar
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

Postby Giovanni » Wed Jan 18, 2017 8:46 am

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

ep.hobbyiest
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

Postby ep.hobbyiest » Mon Apr 03, 2017 7:30 pm

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?

User avatar
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

Postby Giovanni » Mon Apr 03, 2017 9:03 pm

Hi,

Yes, it is possible.

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 44 guests