Page 1 of 1

GPT timer

Posted: Fri May 12, 2017 2:55 pm
by plamen
Hello,
I try to measure the width of a pulse using a general purpose timer. The function is invoked as callback to the EXTD1 driver, triggers on EXTI2 event:

void _extIRQ(EXTDriver *extp, expchannel_t channel)
{
if (_edgeChange == 0) {
gptStartContinuous(&GPTD5, 0); //greatest possible reset value
_edgeChange = 1;
} else {
gptStopTimer(&GPTD5);
_klineCfg.speed = 1000000 / gptGetCounterX(&GPTD5);
}
}

I can't invoke neighter gptStartContinuous nor gptStartContinuousI -> assert of improper I class use. It looks working properly if I disable CH_DBG_ENABLE_CHECKS in chconf.h. Could you please advice what is the proper way to use gptStartContinuous ?

Re: GPT timer

Posted: Sat May 13, 2017 7:40 am
by Giovanni
Hi,

you need to use the I-class functions inside callbacks and ISRs AND you need to call them in between chSysLockFromISR()...chSysUnlockFromISR(). The state checker stops you if do it wrong.

In the RT reference manual there is a section "kernel concepts", read the paragraphs regarding system states and the picture with states.

Giovanni

Re: GPT timer

Posted: Sat May 13, 2017 6:26 pm
by plamen
Thanks!