What is locked after using chSysLock(); ?
Is it possible to make a user defined sleep using chSysLock() and a timer ? (Suppose the timer is already initialized)
void UDSleep (unsigned int sleepDelay){
TIM_SetCounter(TIM2, 0);
TIM_Cmd(TIM2, ENABLE);
chSysLock();
while (TIM_GetCounter(TIM2) < sleepDelay ){
}
chSysUnlock();
}
Thanks,
Jessi
Use chSysLock() to make sleep
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Use chSysLock() to make sleep
Hi,
It is possible but the delay would degrade the realtime performance of the system because no preemption could occur during the lock.
BTW, something similar is already present in the GPT driver, see gptPolledDelay().
Giovanni
It is possible but the delay would degrade the realtime performance of the system because no preemption could occur during the lock.
BTW, something similar is already present in the GPT driver, see gptPolledDelay().
Giovanni
Re: Use chSysLock() to make sleep
Giovanni wrote:Hi,
It is possible but the delay would degrade the realtime performance of the system because no preemption could occur during the lock.
BTW, something similar is already present in the GPT driver, see gptPolledDelay().
Giovanni
Hi,
Thanks for your reply,
Is there anyway to implement a high performance delay?
Jessi
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Use chSysLock() to make sleep
See halPolledDelay() or gptPolledDelay().
For mS-class delays better use chThdSleepMilliseconds().
Giovanni
For mS-class delays better use chThdSleepMilliseconds().
Giovanni
Re: Use chSysLock() to make sleep
Giovanni wrote:See halPolledDelay() or gptPolledDelay().
For mS-class delays better use chThdSleepMilliseconds().
Giovanni
Thanks.
I need higher resolution than mS so I think halPolledDelay() works for me.
Jessi