Page 1 of 1

STM32F7 - thread sleep of a few microseconds

Posted: Tue Mar 06, 2018 4:37 pm
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

Re: STM32F7 - thread sleep of a few microseconds

Posted: Tue Mar 06, 2018 4:42 pm
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

Re: STM32F7 - thread sleep of a few microseconds

Posted: Wed Mar 07, 2018 10:39 am
by elagil
Hello,

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