machine.pwm一直报错ledc channel error

ESP32、ESP8266
ESP32-S2、ESP32-S3、ESP32-C3
回复
dhcxuchao
帖子: 1
注册时间: 2022年 4月 26日 09:14

machine.pwm一直报错ledc channel error

#1

帖子 dhcxuchao »

[img]file:///C:\Users\alienware\AppData\Roaming\Tencent\Users\749459795\QQ\WinTemp\RichOle\TAN[/img]
from machine import Pin,
PWM import time pwm2 = PWM(Pin(33), freq=500, duty=512)
pwm2.deinit()
pwm2.duty(128)
time.sleep(2)
pwm2.duty(256)
time.sleep(2)
pwm2.duty(128)
time.sleep(2)
pwm2.duty(256)
time.sleep(2)

一跑就报错 

>>> from machine import Pin, PWM
>>> pwm2 = PWM(Pin(33), freq=500, duty=512)
>>> pwm2.duty(128)
[0;31mE (349210) ledc: ledc_set_duty(339): LEDC channel error[0m
[0;31mE (349210) ledc: ledc_update_duty(289): LEDC channel error[0m
>>> 

搞不懂了网上查了一下 说 和channel 有关 ,但是pwm 类里面 没有channel 方法加不了?
有没有 老师知道怎么回事的,板子重刷了  没有任何 三方库。
 
 
 

头像
shaoziyang
帖子: 3917
注册时间: 2019年 10月 21日 13:48

Re: machine.pwm一直报错ledc channel error

#2

帖子 shaoziyang »

在第三行将pwm注销了,后面当然就出错了。

pwm2.deinit()

回复

  • 随机主题
    回复总数
    阅读次数
    最新文章