Changing a pin inside a setInterval causes Espruino to hang #6053
Replies: 1 comment
-
Posted at 2018-10-16 by calebbrewer Well... This seems to be an issue with pin 1 on the ESP8266? Posted at 2018-10-16 by @allObjects The first code example surprise me a bit by what it should do... For ten seconds, every five (5) milliseconds it logs "foo ". On the 1000th time, something after five (5) seconds, it turns the pin on. The hanging to me means that something with the buffers goes hi wire, because of all the logging... What is the reason for the loop? ...are you trying to reinstate Arduino on an event driven system? The second piece of code does it 100 times slower: every 500 milliseconds, it does log something... and the rest of the time it is sleeping. Less than a percent - probably 1/2 a percent as busy as the first code... Could it be that the system crashes and reboots?... I would be surprised... PS: ...not Espruino hangs, but ESP8266 Wifi stack puts an end to this...? Posted at 2018-10-16 by @gfwilliams It's pin 1. Check out: http://www.espruino.com/EspruinoESP8266#pinout Pin 1 is D1 - which is USART1_TX. That's the pin that's used by Espruino to output the REPL. So if you write to it, it stops Espruino being able to print anything to the REPL any more. It's still working, it's just not printing anything. Posted at 2018-10-16 by @allObjects ooops... checking the pin vs serial would have helped... ;/ @gfwilliams, w/ your input, I conclude that second example is either not working or tricks the observer that it works only half the times, is it? Adding a counter and log its value would - when working - only log every other time? Posted at 2018-10-16 by @gfwilliams Honestly, I'm not sure why the second would appear to be ok - I'd have thought it would cause the same problems. Posted at 2018-10-19 by calebbrewer Thanks! That is what I found out through trial and error. I forgot to look at what else that pin did. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2018-10-16 by calebbrewer
When I try to change a pin's mode inside a setInterval after a number of loops Espruino hangs.
For example:
It will turn the pin off and log
foo 999
. It will never logfoobar
.The odd thing is that I can create a blink loop with setInterval like this:
Any help would be great!
Beta Was this translation helpful? Give feedback.
All reactions