GPT timer

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

Moderators: RoccoMarco, barthess

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

GPT timer

Postby plamen » Fri May 12, 2017 2:55 pm

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: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: GPT timer

Postby Giovanni » Sat May 13, 2017 7:40 am

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

Postby plamen » Sat May 13, 2017 6:26 pm

Thanks!


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 20 guests