Hi,
I do simple code in one thread just like this
palSetPad(GPIOB,0);
chThdSleepMicrosecond(50);
palClearPad(GPIOB,0);
chThdSleepMicrosecond(50);
but I cannot get 50 microsec delay but it is always 1 msec
I try with STM8S disocovery and STM32discovery board it is the same behavior.
So any way I can do?
Or I have to make my own delay function?
Thank you
Saran
chThdSleepMicrosecond question
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: chThdSleepMicrosecond question
Hi,
The value is always rounded to the current system tick boundary, 1mS in most demos. If you need smaller delays then use the GPT driver, it includes a delay function capable of microseconds resolution (using an hardware timer).
Giovanni
The value is always rounded to the current system tick boundary, 1mS in most demos. If you need smaller delays then use the GPT driver, it includes a delay function capable of microseconds resolution (using an hardware timer).
Giovanni
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: chThdSleepMicrosecond question
It is not a stupid question, I should have specified it.
GPT means General Purpose Timer, it is a new device driver model introduced in 2.3.2, it is not present in the stable version 2.2.x. This driver contains a function named gptPolledDelay() that can be used to introduce small polled delays in the code. An example of use of the GPT driver is present in the test application under ./testhal/STM32/GPT.
Giovanni
GPT means General Purpose Timer, it is a new device driver model introduced in 2.3.2, it is not present in the stable version 2.2.x. This driver contains a function named gptPolledDelay() that can be used to introduce small polled delays in the code. An example of use of the GPT driver is present in the test application under ./testhal/STM32/GPT.
Giovanni