import pyb p = pyb.Pin('P7') # P7 has TIM4, CH1 tim = pyb.Timer(4, freq=1000) ch = tim.channel(1, pyb.Timer.PWM, pin=p) ch.pulse_width_percent(50)
因为代码没有死循环,所以运行完就结束了。没什么错误。