chThdSleepMicrosecond question

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Saran_yim
Posts: 13
Joined: Wed Dec 22, 2010 9:18 am

chThdSleepMicrosecond question

Post by Saran_yim »

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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: chThdSleepMicrosecond question

Post by Giovanni »

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
Saran_yim
Posts: 13
Joined: Wed Dec 22, 2010 9:18 am

Re: chThdSleepMicrosecond question

Post by Saran_yim »

stupid question what is GPT Driver?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: chThdSleepMicrosecond question

Post by Giovanni »

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
Saran_yim
Posts: 13
Joined: Wed Dec 22, 2010 9:18 am

Re: chThdSleepMicrosecond question

Post by Saran_yim »

Thank you Sir.
Post Reply