-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
time.sleep() not working in 6.0.1 in a Blink program #3918
Comments
[Omitting some false starts] Originally posted by @dkirkby in #3829 (comment): Yes, the blink example, saved as import board
import digitalio
import time
led = digitalio.DigitalInOut(board.D13)
led.direction = digitalio.Direction.OUTPUT
while True:
led.value = True
time.sleep(0.5) #### CODE HANGS HERE WITH 6.0.1
led.value = False
time.sleep(0.5) If I replace |
I tried the same blink program above on a Metro M4 Express with 5.3.1, 6.0.1, and 6.1.0-beta.3. They all work and blink as expected, whether plugged into a Linux box or a MacBook running the latest Big Sur. (btw, getting mu to run on Big Sur is a chore, and I gave up. The old alpha supposedly works for some people. See mu-editor/mu#1147) |
I have the same issue on a Feather M4 when plugged into a Mac. Both on Catalina and on Big Sur. |
16” MacBook Pro 2019, happens on all 4 USB-C ports. USB-C to MicroUSB cable connected directly to the Mac without a hub. Now on Big Sur 11.1. |
So, to be precise, when you plug in the board above that already contains a |
Correct, but not always. Sometimes it just works as expected. I initially thought it has something to do with being connected over |
@otherguy I am trying to replicate exactly. On the Feather M4 Express, what version of CircuitPython are you using, and what is the version of the bootloader? You can find the version of the bootloader in FEATHERBOOT (double-click to get it) in |
Circuitpython version 6.0.1 and bootloader v3.10.0 Believe me I would love to be able to replicate it! I thought I'm going crazy and it took me a while to figure out that time.sleep was the issue, when my Neopixel animations started to randomly freeze (time.sleep is used conditionally in my code so it took a while for the issue to pop up). I still cannot reliably replicate it, though. |
What percentage of the time would you say that it happens? I tried about 20 times and could not reproduce. Feather M4 is set up exactly as yours; my MacBook is also Big Sur 11.1, using a USB-C to micro cable. So everything is the same except for the actual MacBook. Is there anything connected to your Feather still, like the string of NeoPixels? I also tried a Feather M0, because we're having other Mac problems with SAMD21. Could not reproduce there either. I'm not doubting you! It's just mysterious. It's not cosmic rays: there's always a reason. |
I cannot give you a percentage. Once it works, it works, for an extended period of time at least. Yes, there are several peripherals connected. A NeoPixel matrix, a TSL2561, an AirLift featherwing (though not in use), a DS3231 and several buttons. I'm thinking it has something to do with the M4 not being recognized correctly. Every time (at least I think it was every time) Right now I cannot reproduce the keyboard dialogue (maybe I would need to reset SMC). |
I am using a 15" 2018 MacBookPro (with 4 usb-c ports) running Catalina 10.15.6. I am connected to a Metro M4 Express powered via usb and running the latest boootloader (v.3.10.0). With CircuitPython 6.0.1 loaded, the blink program hangs in I am entering the code and saving it to the CIRCUITPY drive using the latest stable Mu editor. In other words, I am following the Welcome to CircuitPython tutorial. Having the Mu editor serial tab open or closed makes no difference. Adding some print statements to trace how far the execution goes also makes no difference. If I replace the If I install CircuitPython 5.3.1, the code works as expected. |
I occasionally experienced this on a 2020 iMac running Catalina 10.15.7 and mu 1.0.3. Could not detect a pattern for when it happens. Restarting mu, resetting the board, rebooting the iMac, unplugging USB, etc., sometimes clears the condition, sometimes not. When the code hangs on the Also, an argument of 0 seconds doesn't hang. Tested on a Clue, ItsyBitsy M4 Express, and Feather M4 Express with CircuitPython 6.x.x |
For me it’s exactly the same as for @CedarGroveStudios only I can say with certainty that mu is not involved here. I don’t use it or have it installed. I can also confirm that |
@otherguy @CedarGroveStudios Are you both saying that when you are running a |
I wish I could replicate it for you, but I’m fairly certain it works also when running What I can say with certainty is that when By the way, using the same USB-C cable with a USB-C wall plug never caused a hang so far. |
@dhalbert: It behaved the same when executing the statement in |
In addition to pressing |
@dkirkby @CedarGroveStudios @otherguy Could you test a fix we've worked up? Get a .uf2 for your board from the Artifacts on this page: https://github.com/adafruit/circuitpython/actions/runs/472523484 |
@dhalbert Tested the FYI, using the old |
@CedarGroveStudios Fantastic! Thanks for the test. |
Hope others see the same success. Was the issue related to the USB connection being dropped by the low-power changes to |
There were three bugs fixed: one was actually in the |
@dhalbert this worked instantly, thank you!
(I was hoping it would also fix this issue adafruit/Adafruit_CircuitPython_ESP32SPI#123 but unfortunately no such luck) |
Splitting this issue off from #3829:
from @dkirkby:
I just followed the Welcome to CircuitPython instructions for writing your first program on a Metro M4, using the recommended stable 6.0.1 and Mu editor, and it is now broken because
time.sleep
hangs.Having a working new user tutorial is important, but that could mean simply downgrading the recommended stable release if there isn't a simple fix to the sleep issue.
Originally posted by @dkirkby in #3829 (comment)
The text was updated successfully, but these errors were encountered: