Skip to content

pwm caused crash on esp8266 generic version #7798

@yunfan

Description

@yunfan

mpy ver: v1.17 generic esp8266
board: dmini

description:

the board has a builtin rgb light, which could be control by pin (15, 12, 13)
i want it to do blink over and over, but the code only work for about 2 or 3 times, then the whole program will crash and reboot

here is the code in boot.py

import time
from machine import Pin, Timer, PWM

print("boot start")

def rgbBlink(rv, gv, bv, onTime):
    r, g, b = PWM(Pin(15)), PWM(Pin(12)), PWM(Pin(13))

    r.init(duty=rv)
    g.init(duty=gv)
    b.init(duty=bv)

    time.sleep_ms(onTime)

    r.deinit()
    g.deinit()
    b.deinit()
    
print("before doBlink")
def doBlink():
    tim = Timer(-1)
    tim.init(
            period=3000,
            mode=Timer.PERIODIC,
            callback=lambda t: rgbBlink(255, 128, 128, 1500)
    )

doBlink()
print("after doBlink")

gc.collect()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy