micropython-tm1637 icon indicating copy to clipboard operation
micropython-tm1637 copied to clipboard

Script hanging / freezing

Open MassimoVisona opened this issue 2 years ago • 3 comments

Hello, I was excperiencing some freezing / hanging behaviour with some tm1637 7-segment displays and this library on a Raspberry Pi Pico board. I was able to fix it modifiyng your original library as follows:

  • replace all the "sleep_us" occurrencies with "time.sleep"

  • change the "TM1637_DELAY = const(10)" line with "TM1637_DELAY = const(0.00001)"

  • replace the "from time import sleep_us, sleep_ms" line to "import time"

  • I also changed the "sleep_ms(delay)" inside the scroll function with "time.sleep(delay)" and changed the original "delay=250" with "delay=0.250"

My script is now running since two days with no more freezings! I hope this helps.

MassimoVisona avatar Mar 23 '23 17:03 MassimoVisona

That's interesting. Which version of MicroPython are you running? Have you experienced issues with time.sleep_ms() / time.sleep_us() on any other pico projects?

mcauser avatar Jul 03 '23 00:07 mcauser

I am using MicroPython 1.20. Honestly, it was the first time I used MicroPython, so I have no more experience. I pointed out this solution on the raspberry forum, here you find an excellent reply from hippy.

MassimoVisona avatar Jul 03 '23 14:07 MassimoVisona

I've had the same problem using pi-pico. I raised the issue on the rpi forum, and had useful advice. AIUI:

  1. There's an issue somewhere (I'm not clear whether h'ware or firmware) with timers and interrupts interfering.
  2. the time.sleep_us() function changes its behaviour at 6us,: delays less than this will simply spin, over this do something "more complex".

The current tm1637 module uses delays of 10us when clocking the chip, and falls into the "more complex" arena. After changing to two separate delays of 5us to force a simple, if inefficient, spin, all has been well, and I've not experienced further issues.

See: https://forums.raspberrypi.com/viewtopic.php?t=355111

(And thanks for the code BTW. So good to have all the messy stuff neatly packaged!)

mikescott666 avatar Oct 23 '23 08:10 mikescott666