jsh time functions #5032
Replies: 1 comment
-
Posted at 2015-10-02 by @gfwilliams There's just the header file documentation
On some STM32s they return a value based on the SYSTICK timer, which runs at the clock speed of the device. It means it's nice and quick to get the time as you're basically just reading On Espruino boards there's some insanity that allows them to 'track' the RTC with SysTick - giving accurate times off an LSE crystal white also being accurate to uS.
It's both \o/ It's meant to be accurate down to a uS or so, while big enough to store the date since 1970. If you do To be honest, given ESP8266 isn't going to be very real-time (no 'real' IRQs for GPIO changes(?), and no hardware timer) I'd just run it off the RTC.
It actually sets the time you get from Please could you update the header file with something that makes sense to you? It might help others in the future. Posted at 2015-10-02 by tve I added design thoughts on the clocks and timers to https://github.com/espruino/Espruino/wiki/ESP8266-Design-Notes#system-time. I'll add comments to jshardware.h and you can then review and correct. Posted at 2015-10-03 by tve FYI. I implemented system time. Timers are next... Posted at 2015-10-03 by @gfwilliams Looks fine to me! Posted at 2015-10-03 by tve Question about timers: the hardware timer on the esp8266 cannot do intervals under 100us nor over 8388607 microseconds. I was naively going to use a busy-wait delay for stuff under 100us but that could cause recursive calling of jstUtilTimerInterruptHandler which is "not good". Suggestions? For example, should jshUtilTimerReschedule return false if it can't do the interval? Posted at 2015-10-03 by tve An issue I've run into in implementing the timers is that all functions executed at interrupt time need to be in IRAM. This means that I need to set some Posted at 2015-10-04 by tve I implemented the utilityTimer functions, but I'm not so sure how to test them. I thought that setTimeout would call that, but it doesn't, so I'm a bit puzzled. I then noticed that jshSleep gets called with a delay of (2^63)-1 (-1?) from jsInterative. What is that supposed to do with such a value? Posted at 2015-10-05 by @gfwilliams
That's fine. I'd do:
No - just schedule for the maximum and Espruino will just do the handler, realise nothing is needed, and do nothing.
Wow, that sucks. Could be a pain trying to track that all down, although not as bad as if it executed JS!
Ahh, no - so setTimeout executes JS, but since the JS takes a while to execute I provided some utility stuff that you can use for doing pulses/etc via IRQ. Main one is
On STM32, jshSleep should put the processor to sleep for the amount of time given, so that it wakes either after that time or when there's an IRQ from Serial, GPIO, Utility Timer, SysTick, etc. If setDeepSleep is 1 and there's nothing in the utility timer then it'll go into proper low power sleep. If it's given 0xFFF..FFF then that means it should only wake up if there's an IRQ - not after a time period. Posted at 2015-10-05 by tve Thanks for the clarifications! WRT jshSleep, since there's this funny main loop task thing in the esp8266 that means that any esp8266 interrupt handler or network callback needs to somehow kick-start the main loop task again if it's asleep. That's gonna a bit a maintenance headache, but certainly doable. Posted at 2015-10-05 by @gfwilliams To be honest I think a minor rewrite would fix it. I think it currently looks like:
But we could do:
In which case suddenly in ESP8266 you've got the sleep time available at the end, so you can reschedule the callback at the right time? You could hack it in right now just by doing the following though?
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-10-02 by tve
Where can I find information about what the various jsh time functions are intended to do? E.g. jshGetSystemTime, jshSetSystemTime, jshGetMillisecondsFromTime, jshGetTimeFromMilliseconds
Specifically:
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions