STM32F7 - thread sleep of a few microseconds

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

Moderators: RoccoMarco, barthess

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

STM32F7 - thread sleep of a few microseconds

Postby elagil » Tue Mar 06, 2018 4:37 pm

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: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: STM32F7 - thread sleep of a few microseconds

Postby Giovanni » Tue Mar 06, 2018 4:42 pm

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: 92
Joined: Tue Sep 19, 2017 7:38 am
Has thanked: 8 times
Been thanked: 7 times

Re: STM32F7 - thread sleep of a few microseconds

Postby elagil » Wed Mar 07, 2018 10:39 am

Hello,

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


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 19 guests