Time keeping with utime

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
priis
Posts: 26
Joined: Tue Mar 31, 2015 9:52 pm

Time keeping with utime

Post by priis » Tue Sep 25, 2018 9:46 pm

Some days ago I bought an esp32 and a pysense board. After several hours of struggling I can now read all the sensors of the pysense board.
However, for the time keeping I would like to measure time in seconds with at least one decimal.
I tried
start=time.ticks_ms()
followed by
print( time.ticks_diff(start, time.ticks_ms()))

only resulting in the following error message (and a lot more garbage):

Guru Meditation Error of type LoadProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x400ed168 PS : 0x00060f30 A0 : 0x800fd348 A1 : 0x3ffc6120
A2 : 0x00000000 A3 : 0x00060f23 A4 : 0x00060f20 A5 : 0x00000002
A6 : 0x0000002a A7 : 0x3ffc62f0 A8 : 0x00000000 A9 : 0x3ffc6110
A10 : 0x00000000 A11 : 0x00060f23 A12 : 0x00060f20 A13 : 0x00000000
A14 : 0x0000000a A15 : 0x3ffc62d0 SAR : 0x0000000c EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000

Backtrace: 0x400ed168:0x3ffc6120 0x400fd348:0x3ffc6140 0x400ef3d9:0x3ffc6160 0x400eb9d8:0x3ffc6180 0x400eba40:0x3ffc61a0 0x400f75b8:0x3ffc61c0 0x400ef48b:0x3ffc6260 0x400eb9d8:0x3ffc62f0 0x400eba05:0x3ffc6310 0x400d948e:0x3ffc6330 0x400d972f:0x3ffc63d0 0x400d885f:0x3ffc6410

================= CORE DUMP START =================
9CEAAAoAAABsAQAA
QET8P2Bg/D+oZfw/
AGL8P0Bl/D+mswIAUEH8P1BB/D9ARPw/SEH8PxQAAAAAAAAAAAAAAEBE/D8AAAAA
BQAAAKxF/D9NaWNyb1B5AAAAAAAAAAAAAAAAAKhl/D8AAAAAIQAGAAUAAAABAAAA
AAAAAAxt/D8AAAAAAAAAAAAAAACYZPk/eGT5P1hk+T8AAAAAAAAAAAEAAAAAAAAA
pM5CPwAAAABIHQBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAA==



I also tried utime with no better results.
How can I get an accurate time keeping with micropython?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Time keeping with utime

Post by Roberthh » Wed Sep 26, 2018 5:20 am

That seems to be the wrong forum for your questions, since pysense is a Pycom product. You may better ask at forum.pycom.io.
Besides that, it is not clear why ticks_ms and ticks_diff should cause a core dump. Please post also you firmware version and the ESP32 board model.

priis
Posts: 26
Joined: Tue Mar 31, 2015 9:52 pm

Re: Time keeping with utime

Post by priis » Wed Sep 26, 2018 6:49 pm

I use esp32-20180920-v.1.9.4-560-g185716514.
I thought that micropython is micropython but I have seen so many strange errors (some times my programs run perfectly, other times the very same programs crash with mysterious error messages). So now I have the suspicion that I use the wrong firmware for my esp32 pycom wipy3.0 wifi Bluetooth module. But what is then the correct firmware? And where can I find it?

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Time keeping with utime

Post by jickster » Wed Sep 26, 2018 6:59 pm

priis wrote:
Wed Sep 26, 2018 6:49 pm
I use esp32-20180920-v.1.9.4-560-g185716514.
I thought that micropython is micropython but I have seen so many strange errors (some times my programs run perfectly, other times the very same programs crash with mysterious error messages). So now I have the suspicion that I use the wrong firmware for my esp32 pycom wipy3.0 wifi Bluetooth module. But what is then the correct firmware? And where can I find it?
http://micropython.org/download#esp32

priis
Posts: 26
Joined: Tue Mar 31, 2015 9:52 pm

Re: Time keeping with utime

Post by priis » Wed Sep 26, 2018 7:15 pm

... Sorry, my firmware is
MicroPython v1.8.6-621-g17ee404e on 2017-05-25; WiPy with ESP32

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Time keeping with utime

Post by jickster » Wed Sep 26, 2018 7:21 pm

priis wrote:... Sorry, my firmware is
MicroPython v1.8.6-621-g17ee404e on 2017-05-25; WiPy with ESP32
But what’s your hardware?


Sent from my iPhone using Tapatalk Pro

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

Re: Time keeping with utime

Post by pythoncoder » Thu Sep 27, 2018 7:33 am

If you're running PyCom hardware you should run their firmware: MicroPython is customised to specific hardware platforms. You'll get more knowledgeable answers to questions on PyCom kit if you raise them in the PyCom forum.
Peter Hinch
Index to my micropython libraries.

priis
Posts: 26
Joined: Tue Mar 31, 2015 9:52 pm

Re: Time keeping with utime

Post by priis » Thu Sep 27, 2018 10:07 am

And how to flash it?
I tried ESP8266 flasher but that didn't work.
Next, I tried the following from a DOS terminal window:
esptool.py --chip esp32 --port COM7 write_flash -z 0x1000 esp32-20180511-v1.9.4.bin
but I get an error message:
epstool: error: argument operation: invalid choice: 'esp32' (choose from 'load_ram' ...).

What is the exact syntax?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Time keeping with utime

Post by Roberthh » Thu Sep 27, 2018 10:39 am

You should get a recent copy of esptool.py, e.g. from this place: https://github.com/espressif/esptool

priis
Posts: 26
Joined: Tue Mar 31, 2015 9:52 pm

Re: Time keeping with utime

Post by priis » Thu Sep 27, 2018 4:46 pm

Thanks, I have done that. But again, what is the exact syntax of the esptool command?
I have tried several variations of
esptool.py --chip esp32 --port COM7 write_flash -z 0x1000 esp32-20180927-v1.9.4-584-g57a7d5be9.bin
- none of them works.

Post Reply