GPTs not stoped in Continuous mode

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
Exeland
Posts: 12
Joined: Sat Jun 06, 2015 4:33 pm

GPTs not stoped in Continuous mode

Post by Exeland »

When the timer is running in continuous mode , it is not possible to stop. The function gpt_lld_stop can stop the timer only if the value of the status GPT_READY, and in this mode, the status GPT_CONTINUOUS. It is an error code or something I 'm doing wrong ?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: GPTs not stoped in Continuous mode

Post by Giovanni »

Hi,

It should work in any state, this is the performed check:

Code: Select all

 chDbgAssert((gptp->state == GPT_READY) || (gptp->state == GPT_CONTINUOUS) ||
              (gptp->state == GPT_ONESHOT),
              "gptStopTimerI(), #1", "invalid state");


Are you experiencing something different?

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: GPTs not stoped in Continuous mode

Post by Giovanni »

Sorry, I misunderstood, you have first to call gptStopTimer() then gptStop().

gptStopTimer() stops the continuous operation, gptStop() stops the whole driver.

Giovanni
Exeland
Posts: 12
Joined: Sat Jun 06, 2015 4:33 pm

Re: GPTs not stoped in Continuous mode

Post by Exeland »

I use Chibios 2.6.8.(whit mcu stm32f401)
My code:

Code: Select all

          
gptStart(&GPTD2, &Player_GPT_cfg);
gptStartContinuous(&Player_GPT, PLAYER_GPT_INTERVAL);
...
gptStop(&GPTD2);

In file /os/os/hal/platforms/STM32/TIMv1/gpt_lld.c function gpt_lld_stop, not stop timer:

Code: Select all

void gpt_lld_stop(GPTDriver *gptp) {

  if (gptp->state == GPT_READY) {
    gptp->tim->CR1  = 0;                        /* Timer disabled.          */
    gptp->tim->DIER = 0;                        /* All IRQs disabled.       */
    gptp->tim->SR   = 0;                        /* Clear pending IRQs.      */
...


Sorry for my English.
Exeland
Posts: 12
Joined: Sat Jun 06, 2015 4:33 pm

Re: GPTs not stoped in Continuous mode

Post by Exeland »

I think it should be a function gpt_lld_stop of :

Code: Select all

 
 if (gptp->state != GPT_UNINIT) {
    gptp->tim->CR1  = 0;                        /* Timer disabled.          */
    gptp->tim->DIER = 0;                        /* All IRQs disabled.       */
    gptp->tim->SR   = 0;                        /* Clear pending IRQs.      */
...

And it work.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: GPTs not stoped in Continuous mode

Post by Giovanni »

Please read my previous answer, gptStop() is not meant to stop the current operation, you have to use gptStopTimer() for that.

If you enable the state checker in chconf.h you would get an usage violation from using gptStop() while an operation is in progress.

Giovanni
Exeland
Posts: 12
Joined: Sat Jun 06, 2015 4:33 pm

Re: GPTs not stoped in Continuous mode

Post by Exeland »

Ok. Thanks.
Post Reply