logo

p7p8p9以外的io口如何输出PWM?直接将Timer里的第一参数改为定时器1会报错

2022-03-09 22:15
R
RAIN
cdf22a73-2475-4d8a-9065-9df6ca85f439.png
a054bcd3-a443-4d80-ae53-5ad7be052e02.png
2022-03-10 18:33
I
网红小智智 星瞳科技

如果涉及代码,需要报错提示与全部代码文本,请注意不要贴代码图片

2022-03-11 11:59
R
RAIN

@kidswong999 P7P8P9以外的Iio口如何输出PWM

2022-03-14 19:06
I
网红小智智 星瞳科技

timer1 用不了,因为摄像头采集用了timer1

import sensor, image, time
from pyb import Pin, Timer

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)

tim = Timer(2, freq=1000) # Frequency in Hz
ch3 = tim.channel(3, Timer.PWM, pin=Pin("P4"), pulse_width_percent=50)

clock = time.clock()
while(True):
    clock.tick()
    img = sensor.snapshot()
    print(clock.fps())