STM32F7 - thread sleep of a few microseconds

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

Moderator: RoccoMarco

Post Reply
elagil
Posts: 94
Joined: Tue Sep 19, 2017 7:38 am
Has thanked: 8 times
Been thanked: 7 times

STM32F7 - thread sleep of a few microseconds

Post by elagil »

Hello!

I want to make a polling based one-wire driver because I want to be able to use it on multiple pins without occupying PWM/Timer blocks. Therefore, I need delays in the range of a few microseconds. I tried using

Code: Select all

chThdSleepMicroseconds(n)


in conjunction with

Code: Select all

#define CH_CFG_ST_FREQUENCY                 1000000


so that systick is 1 MHz. So, I should be able to resolve 1 us ticks with some inaccuracy due to

Code: Select all

#define CH_CFG_ST_TIMEDELTA                 2


I now try to toggle a pin and place a 10 microsecond delay between setLine and clearLine operations. The delay between the switching is never below 40 us. Am I missing something here? Why can the delay not be less than this?

The processor runs at 200 MHz.

Thanks in advance,
Adrian
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F7 - thread sleep of a few microseconds

Post by Giovanni »

Hi,

You have to consider jitter in the system, you cannot have such accurate delays when ISRs take several microseconds.

You may use the "polled" delay functions in both Kernel (chSysPolledDelayX()) and HAL (gptPolledDelay()) but those would still be partially affected by IRQ-caused jitter.

Giovanni
elagil
Posts: 94
Joined: Tue Sep 19, 2017 7:38 am
Has thanked: 8 times
Been thanked: 7 times

Re: STM32F7 - thread sleep of a few microseconds

Post by elagil »

Hello,

the gptPolledDelay works fine for my case, thank you! I get the delays with sufficient accuracy.
Post Reply