Timing problem (10us) Topic is solved

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

Moderator: RoccoMarco

Post Reply
danitoth91
Posts: 3
Joined: Thu Dec 18, 2014 3:08 pm

Timing problem (10us)

Post by danitoth91 »

Dear Giovanni,

I have a timing problem with tasks. I would like to create a task which repeats every 10us. Inside this
task i would like to use SPI. Unfortunately i can't create a task with 10us periodity. The minimum
delay was 200us i can reach. I have tried to use SPI within a GPT callback but it wasn't work.

Do you have any idea to solve this problem?

Thank you very much,
Daniel
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: Timing problem (10us)

Post by RoccoMarco »

Hi,
do you have any idea about the lasting of your SPI operation?
If you make an SPIStartExchangeI inside the gpt callback you have to ensure that it least less than 10us

By the way it should be

Code: Select all

spicb (...) {

chSysLock();
SPIUnselectI(...);
chSysUnlock();
}


gptcb (...) {

chSysLock();
SPISelectI(...);
SPIExchangeI(...);
chSysUnlock();
}


Ciao,
RM
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Timing problem (10us)

Post by Giovanni »

Hi,

The minimum interval depends on the system tick frequency, if the system tick is 10kHz then your intervals will be aligned to the next 100uS boundary.

Giovanni
danitoth91
Posts: 3
Joined: Thu Dec 18, 2014 3:08 pm

Re: Timing problem (10us)

Post by danitoth91 »

How should we modify the "CH_CFG_ST_FREQUENCY" to reach the 10us task? When we tried to increase the frequency it cause that the shell doesn't work. Do you have any idea?

Thank you very much.

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

Re: Timing problem (10us)

Post by Giovanni »

Hi,

There are practical limits to the system tick frequency, you can't expect to have 10 uS accurate delays.

It is best if you use a GPT timer for intervals and do operations from its callback like RM proposed.

Giovanni
danitoth91
Posts: 3
Joined: Thu Dec 18, 2014 3:08 pm

Re: Timing problem (10us)

Post by danitoth91 »

I could make it with GPT, it was my mistake.
Thank you guys!
Post Reply