microsoft / devkit-sdk

Arduino library and package for the MXChip IoT DevKit
https://aka.ms/devkit
MIT License
69 stars 52 forks source link

millis() value less then 4294967 (about 1.2hours) #1053

Closed matsujirushi closed 4 years ago

matsujirushi commented 4 years ago

Return type of millis() is uint32_t.
0~2^32-1.

But I got maximum value of millis() is (2^32-1)/1000.

Please see this code.

github-actions[bot] commented 4 years ago

This issue has no recent activities, please take a look and provide updates for it.

JerryYangKai commented 4 years ago

@matsujirushi I have checked the code, and found us_ticker_read() return type is uint32_t, so its maximum value is 2^32-1. And in function millis(), it divide 1000 of us_ticker_read()'s return , so millis() can only return (2^32-1)/1000.

matsujirushi commented 4 years ago

I see. I want to fix it because Arduino API defined that.

JerryYangKai commented 4 years ago

@matsujirushi Sure! I suggest rename current millis() to anothor name and you can write a new millis() as Arduino API defined. Thanks!

JerryYangKai commented 4 years ago

@matsujirushi Since 1.6.5 is a stable version, so I will fixed it in the next released. You can change your local sdk for temporary work around.

JerryYangKai commented 4 years ago

Hi @matsujirushi, I checked the open source mbed code and found there are only 32 bit to store the counter, so it has limited in millis(). We have already provided an api for millis count, it is in SystemTickCounter.h.