Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Timeout of less than 10ms in setInterval seems to hang #140

Closed
grgustaf opened this issue Aug 25, 2016 · 4 comments
Closed

Timeout of less than 10ms in setInterval seems to hang #140

grgustaf opened this issue Aug 25, 2016 · 4 comments
Labels

Comments

@grgustaf
Copy link
Contributor

Clock ticks on Arduino 101 default to 100 per second, I believe, or 10ms intervals. So this is probably related to that and the fact that we currently sleep for a tick in our main loop.

@jprestwo, you might be interested to look into this.

@grgustaf
Copy link
Contributor Author

I assume this problem is easily reproducible, but if not, I'm running into it on a Love-o-Meter.js sample that I'll check in shortly.

@jprestwo
Copy link
Contributor

I am not seeing this problem when I tested it (Love-o-Meter.js is not checked in yet). I ran the following code:

var i = 0;
setInterval(function() {
    print("test: " + i++);
}, 1);

Maybe the print is causing enough delay to throw it off? @grgustaf were you just blinking an LED maybe?

@haoxli
Copy link
Contributor

haoxli commented Aug 30, 2016

@jprestwo If you add more code in setInterval(), it will be reproduced.
I think this issue occur by the execution time of code block is larger than the timeout, the next loop of setInterval() will hang because the previous one have not finished.

@grgustaf
Copy link
Contributor Author

Works for me, with timeout of 1, 0.5, 0.1, and even 0. (Not sure if it really pays attention to sub-1ms timeouts.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants