Page 1 of 1

Problem calling gptStartOneShotI from EXT callback

Posted: Sun Aug 19, 2012 7:14 am
by wypoon
Target: STM32F407
Ver: Trunk

I'm getting the debug assertion error below when I try to use gptStartOneShotI() from within my EXT callback:
chDbgAssert(gptp->state == GPT_READY,"gptStartContinuousI(), #1", "invalid state") // gpt.c

main() {
gptStart(&GPTD2, &gpt2cfg);
gptPolledDelay(&GPTD2, 1000);
extStart(&EXTD1, &extcfg);
}

extcb1 {
chSysLockFromIsr();
gptStartOneShotI(&GPTD2, 200);
chSysUnlockFromIsr();
}

Am I doing something wrong, or is this a bug? Thanks....!

Re: Problem calling gptStartOneShotI from EXT callback

Posted: Sun Aug 19, 2012 7:54 am
by Giovanni
Hi,

It is possible you get two EXT callbacks in short time and the second one fails because the GPT is already active. Could you confirm if this is the case?

If so you could check the GPT ste before invoking gptStartOneShot() to check if has already been triggered.

Giovanni

Re: Problem calling gptStartOneShotI from EXT callback

Posted: Sun Aug 19, 2012 8:45 am
by wypoon
Yup, that was it! I shouldn't have assumed that the monostable implementation was retriggerable :mrgreen: Thanks!

Re: Problem calling gptStartOneShotI from EXT callback

Posted: Sun Aug 19, 2012 8:48 am
by Giovanni
Actually, adding a retriggerable variant or just make it retriggerable is not a bad idea.

Giovanni