Page 1 of 1

Timing problem (10us)

Posted: Tue Jul 05, 2016 11:09 am
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

Re: Timing problem (10us)

Posted: Tue Jul 05, 2016 11:50 am
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

Re: Timing problem (10us)

Posted: Tue Jul 05, 2016 12:26 pm
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

Re: Timing problem (10us)

Posted: Tue Jul 05, 2016 1:14 pm
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

Re: Timing problem (10us)

Posted: Tue Jul 05, 2016 1:27 pm
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

Re: Timing problem (10us)

Posted: Tue Jul 05, 2016 5:14 pm
by danitoth91
I could make it with GPT, it was my mistake.
Thank you guys!