GPT timer

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

Moderator: RoccoMarco

Post Reply
plamen
Posts: 11
Joined: Thu Feb 02, 2017 9:47 am
Has thanked: 1 time
Been thanked: 2 times

GPT timer

Post 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 ?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: GPT timer

Post 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
plamen
Posts: 11
Joined: Thu Feb 02, 2017 9:47 am
Has thanked: 1 time
Been thanked: 2 times

Re: GPT timer

Post by plamen »

Thanks!
Post Reply