【问题标题】:init Uart pins as PWM out初始化 Uart 引脚作为 PWM 输出
【发布时间】:2021-01-15 20:56:40
【问题描述】:

在 Feather m0 basic 上使用 circuitPython,我无法同时使用板针 10 和 11 作为 PWM 输出。

它们都分别使用pwmio.PWMOut(),但如果我尝试同时初始化它们,程序就会崩溃。

我发现这些是 UART 引脚。有没有办法将这些引脚配置为同时作为 PWM 输出?

【问题讨论】:

    标签: uart pwm adafruit-circuitpython


    【解决方案1】:

    我不确定您指的是哪个引脚,但这在 CircuitPython 6.0.1 上的 Adafruit Feather M0 Bluefruit 上看起来不错,这是 REPL 的一个示例:

    Adafruit CircuitPython 6.0.1 on 2020-12-28; Adafruit Feather M0 Adalogger with samd21g18
    >>>
    >>> import boardpulseio
    >>> pwm_d11 = pulseio.PWMOut(board.D11)
    >>> pwm_d12 = pulseio.PWMOut(board.D12)
    >>> pwm_d11.duty_cycle = 10000
    >>> pwm_d11.duty_cycle = 12000
    >>> pwm_d12.duty_cycle = 40000
    >>> pwm_d12.duty_cycle = 38000
    >>> pwm_tx = pulseio.PWMOut(board.TX)
    >>> pwm_rx = pulseio.PWMOut(board.RX)
    >>> pwm_tx.duty_cycle = 12345
    >>> pwm_rx.duty_cycle = 54321
    

    你的和那个有什么不同?错误信息是什么?

    您是使用variable_frequency 还是指定不同的频率?这会导致在幕后使用更多的硬件计数器。

    【讨论】:

      猜你喜欢
      • 2011-06-24
      • 2017-04-20
      • 2011-10-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-02
      • 2018-12-18
      • 2015-04-27
      • 1970-01-01
      相关资源
      最近更新 更多