-->
Page 1 of 1

tmr.now vs tmr.time() bug?

PostPosted: Wed Feb 18, 2015 11:45 am
by MikeV
I'm new to Lua, so perhaps this is by design, but if I create two functions:
Code: Select allnowtest=function()
    for i=1,5 do
        print(tmr.now())
        tmr.delay(1000000)
    end
end
and
Code: Select alltimetest=function()
    for i=1,5 do
        print(tmr.time())
        tmr.delay(1000000)
    end
end
and then run the functions, "nowtest" prints a sequence of numbers incrementing as I'd expect e.g.:
605053390 606055199 607056705 608058206 609059708
but "timetest" prints the same number on each iteration of the for..end loop, although each time you run the function it updates to the latest time. e.g.
> timetest() --1685 1685 1685 1685 1685
> timetest() --1691 1691 1691 1691 1691
The definition for tmr.time) is "return rtc time since start up in second, uint31 form." whereas tmr.now is "return the current value of system counter: uint31, us."
Is this right? Or is it a bug? If not a bug perhaps someone could explain the difference in behaviour.

Re: tmr.now vs tmr.time() bug?

PostPosted: Thu Feb 19, 2015 11:03 pm
by vowstar
The tmr is based software timer in espressif SDK.
If CPU is fully used, the SDK's software timer will stop.
May be the FreeRTOS based SDK will solve this problem.