Overflow values for time counters

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Overflow values for time counters

Post by devnull » Mon May 28, 2018 1:01 am

I have googled and searched these forums but can't find an answer.

How can I determine what is the max / overflow values for:

1) time.time()
2) time.ticks_cpu()
3) time.ticks_ms()
4) time.ticks_us()

I know that ticks_ms and ticks_us can handle rollover / overflow, but is there a maximum period that they can measure ?

Many Thanks

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Overflow values for time counters

Post by devnull » Mon May 28, 2018 2:31 am

OK, I can't use ticks as that gets reset after deepsleep, so what I am looking for is the max / overflow value for time.time()

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Overflow values for time counters

Post by pythoncoder » Mon May 28, 2018 5:42 am

On bare metal ports utime.time() returns an integer as a number of seconds since Y2K. Since Python integers have arbitrary precision it should never overflow. The RTC hardware on STM chips looks like it supports dates up to 2099.

But to some extent I'm guessing, I haven't trawled through ports/stm32/rtc.c.

You don't mention your hardware but as far as I can recall the ESP8266 RTC breaks after about 7 hours.
Peter Hinch
Index to my micropython libraries.

Post Reply