Left here for archival purposes.

User avatar
By MikeV
#10103 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.
User avatar
By vowstar
#10190 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.