Page 1 of 1

GPTs not stoped in Continuous mode

Posted: Sat Jun 06, 2015 4:52 pm
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 ?

Re: GPTs not stoped in Continuous mode

Posted: Sat Jun 06, 2015 7:52 pm
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

Re: GPTs not stoped in Continuous mode

Posted: Sat Jun 06, 2015 8:31 pm
by Giovanni
Sorry, I misunderstood, you have first to call gptStopTimer() then gptStop().

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

Giovanni

Re: GPTs not stoped in Continuous mode

Posted: Sat Jun 06, 2015 10:53 pm
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.

Re: GPTs not stoped in Continuous mode

Posted: Sat Jun 06, 2015 11:00 pm
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.

Re: GPTs not stoped in Continuous mode

Posted: Sun Jun 07, 2015 6:25 am
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

Re: GPTs not stoped in Continuous mode

Posted: Sun Jun 07, 2015 6:46 am
by Exeland
Ok. Thanks.