Lora-net / LoRaMac-node

Reference implementation and documentation of a LoRa network node.
Other
1.88k stars 1.09k forks source link

Two or more timers eventually stop #85

Closed ChrisEAlfred closed 8 years ago

ChrisEAlfred commented 8 years ago

I wrote a simple test application that starts 2 timers. One timer is 500ms the second is 1000ms. They are started, and when elapsed, they are stopped and restarted.

After a random amount of time, but usually within 10s, the timers both stop - it is as though the TimeStart routine does not start timers any more due to a race condition.

If only one timer is running, all works correctly.

I have attached the code. The BoardDebug() is a custom routine prints debug via serial port.

This code is running on an STM32F411 Nucleo board. Admittedly, the HAL low power is different on the F411, so low power is disabled for now.

`#include

include

include "board.h"

define USE_BOTH_TIMERS 1

/*!

/*!

/**

TimerInit( &Test2Timer, OnTest2TimerEvent );
TimerSetValue( &Test2Timer, 1000 );
TimerStart( &Test2Timer );

endif

while( 1 )
{
    // Heartbeat
    if (HAL_GetTick() - lastHeartbeatTick >= 1000)
    {
        lastHeartbeatTick = HAL_GetTick();
        GpioToggle(&Led4);
        BoardDebug("[Beat]\r\n");
    }

    if (test1TimerEvent)
    {
        test1TimerEvent = false;
        result = TimerStart( &Test1Timer );
        BoardDebug("Test1Timer %04X\r\n", result);
    }

if USE_BOTH_TIMERS

    if (test2TimerEvent)
    {
        test2TimerEvent = false;
        result = TimerStart( &Test2Timer );
        BoardDebug("Test2Timer %04X\r\n", result);
    }

endif

}

} `

ChrisEAlfred commented 8 years ago

The last successful TimerStart call always executes timer.c :: TimerStart clause:

    if( obj->Timestamp < remainingTime )
    {
        TimerInsertNewHeadTimer( obj, remainingTime );
        result |= 0x20; // debug that we got here
    }

But it is not the first time that it ran this part of the code.

shankar-vv commented 8 years ago

I am using STM32L073 uC. I also have disabled the low power mode. I can see that after running well for sometime, the timer stops. The time when timer stops is random. Sometimes it can run few hours, sometimes few mins.

ChrisEAlfred commented 8 years ago

I now have an STM32L152RET6 Nucleo board (NUCLEO-L152RE) which is the closest I could get to the SensorNode which uses an STM32L151.

This means that I can use the exact same code and use ultra-low power mode.

The NUCLEO-L152RE also exhibits the timer stopping. I think this is a real bug in LoRa-net timer handling.

shakuuuu, were you running my example code? If you were running the normal LoRa examples, the probability is much lower which could explain why it took longer for it to happen on your board.

ChrisEAlfred commented 8 years ago

Still testing, but it looks like if you schedule another timer event to occur at the same millisecond as the timer event on the head, then the timers stop.

shankar-vv commented 8 years ago

@ChrisEAlfred yes I have been using the Sensor Node code. In this application case,most of the time, the timer stop is not so soon. I had to let it run overnight sometimes to simulate the issue.

dubanoze commented 8 years ago

Guys, hello. Are you find solution ? I have same.

dubanoze commented 8 years ago

Guys, which version you use ? i see RTC major update on 1 Jun. They rewrote rtc & timers code.

MichaelDevid commented 8 years ago

Any news on this? I have run into issues of the RTC interrupt not firing anymore after a 5-10 seconds of running. But only when I use the STM32L151xE.h include instead of the stm32l151xb.h but my MCU is a stm32l151RE.

adonislixi commented 8 years ago

We encounter the same problem! we use "startTime" to light on LED by using STM32l052c8t6 , it can run all night long. But, when I chang ping-pong demo ,it only can run first or several timer. then it never go into RTC interrupt handler........

is that a bug in SDK??

adonislixi commented 8 years ago

Hi everyone, this issue can handle the RTC problem

123

mluis1 commented 8 years ago

Can we close the issue?

adonislixi commented 8 years ago

I think so ..

adonislixi@foxmail.com

From: Miguel Luis Date: 2016-09-23 15:49 To: Lora-net/LoRaMac-node CC: adonis lee; Manual Subject: Re: [Lora-net/LoRaMac-node] Two or more timers eventually stop (#85) Can we close the issue? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.